]> diplodocus.org Git - nmh/commitdiff
oauth: Replace `if...return false; return true' with `return ...'.
authorRalph Corderoy <ralph@inputplus.co.uk>
Mon, 4 Sep 2017 09:42:17 +0000 (10:42 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Mon, 4 Sep 2017 09:42:17 +0000 (10:42 +0100)
In functions returning bool, these are equivalent.

    Before:                 After:
        if (!foo())             return foo();
            return false;
        return true;

sbr/oauth.c
sbr/oauth_prof.c

index e91e0bb..ec485cd 100755 (executable)
@@ -971,14 +971,10 @@ post(struct curl_ctx *ctx, const char *url, const char *req_body)
         return false;
     }
 
-    if (curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,
-                                    &ctx->res_code) != CURLE_OK
-        || curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE,
-                                       &ctx->content_type) != CURLE_OK) {
-        return false;
-    }
-
-    return true;
+    return curl_easy_getinfo(curl,
+            CURLINFO_RESPONSE_CODE, &ctx->res_code) == CURLE_OK &&
+        curl_easy_getinfo(curl,
+            CURLINFO_CONTENT_TYPE, &ctx->content_type) == CURLE_OK;
 }
 
 /*******************************************************************************
@@ -1019,11 +1015,8 @@ parse_json(jsmntok_t **tokens, size_t *tokens_len,
            of the response body. */
         *tokens = mh_xrealloc(*tokens, *tokens_len * sizeof **tokens);
     }
-    if (r <= 0) {
-        return false;
-    }
 
-    return true;
+    return r > 0;
 }
 
 /*
index 26132fa..b541638 100644 (file)
@@ -124,11 +124,7 @@ mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo,
         }
     }
 
-    if (!update_svc(svcinfo, svc_name, errbuf, errbuflen)) {
-        return false;
-    }
-
-    return true;
+    return update_svc(svcinfo, svc_name, errbuf, errbuflen);
 }
 
 const char *