1313#include "options.h"
1414
1515#define DOH_CONTENT_TYPE "application/dns-message"
16- #define DOH_MAX_RESPONSE_SIZE 65535
16+ enum {
17+ DOH_MAX_RESPONSE_SIZE = 65535
18+ };
1719
1820// the following macros require to have ctx pointer to https_fetch_ctx structure
1921// else: compilation failure will occur
@@ -354,8 +356,8 @@ static int https_fetch_ctx_process_response(https_client_t *client,
354356 }
355357 }
356358
357- if (( res = curl_easy_getinfo (
358- ctx -> curl , CURLINFO_RESPONSE_CODE , & long_resp )) != CURLE_OK ) {
359+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_RESPONSE_CODE , & long_resp );
360+ if ( res != CURLE_OK ) {
359361 ELOG_REQ ("CURLINFO_RESPONSE_CODE: %s" , curl_easy_strerror (res ));
360362 faulty_response = 1 ;
361363 } else if (long_resp != 200 ) {
@@ -389,8 +391,8 @@ static int https_fetch_ctx_process_response(https_client_t *client,
389391
390392 if (!faulty_response )
391393 {
392- if (( res = curl_easy_getinfo (
393- ctx -> curl , CURLINFO_CONTENT_TYPE , & str_resp )) != CURLE_OK ) {
394+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_CONTENT_TYPE , & str_resp );
395+ if ( res != CURLE_OK ) {
394396 ELOG_REQ ("CURLINFO_CONTENT_TYPE: %s" , curl_easy_strerror (res ));
395397 } else if (str_resp == NULL ||
396398 strncmp (str_resp , DOH_CONTENT_TYPE , sizeof (DOH_CONTENT_TYPE ) - 1 ) != 0 ) { // at least, start with it
@@ -400,23 +402,25 @@ static int https_fetch_ctx_process_response(https_client_t *client,
400402 }
401403
402404 if (logging_debug_enabled () || faulty_response || ctx -> buflen == 0 ) {
403- if (( res = curl_easy_getinfo (
404- ctx -> curl , CURLINFO_REDIRECT_URL , & str_resp )) != CURLE_OK ) {
405+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_REDIRECT_URL , & str_resp );
406+ if ( res != CURLE_OK ) {
405407 ELOG_REQ ("CURLINFO_REDIRECT_URL: %s" , curl_easy_strerror (res ));
406408 } else if (str_resp != NULL ) {
407409 WLOG_REQ ("Request would be redirected to: %s" , str_resp );
408410 if (strcmp (str_resp , client -> opt -> resolver_url ) != 0 ) {
409411 WLOG ("Please update Resolver URL to avoid redirection!" );
410412 }
411413 }
412- if ((res = curl_easy_getinfo (
413- ctx -> curl , CURLINFO_SSL_VERIFYRESULT , & long_resp )) != CURLE_OK ) {
414+
415+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_SSL_VERIFYRESULT , & long_resp );
416+ if (res != CURLE_OK ) {
414417 ELOG_REQ ("CURLINFO_SSL_VERIFYRESULT: %s" , curl_easy_strerror (res ));
415418 } else if (long_resp != CURLE_OK ) {
416419 WLOG_REQ ("CURLINFO_SSL_VERIFYRESULT: %s" , curl_easy_strerror (long_resp ));
417420 }
418- if ((res = curl_easy_getinfo (
419- ctx -> curl , CURLINFO_OS_ERRNO , & long_resp )) != CURLE_OK ) {
421+
422+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_OS_ERRNO , & long_resp );
423+ if (res != CURLE_OK ) {
420424 ELOG_REQ ("CURLINFO_OS_ERRNO: %s" , curl_easy_strerror (res ));
421425 } else if (long_resp != 0 ) {
422426 WLOG_REQ ("CURLINFO_OS_ERRNO: %d %s" , long_resp , strerror (long_resp ));
@@ -428,8 +432,8 @@ static int https_fetch_ctx_process_response(https_client_t *client,
428432 }
429433
430434 if (logging_debug_enabled () || client -> stat ) {
431- if (( res = curl_easy_getinfo (
432- ctx -> curl , CURLINFO_NUM_CONNECTS , & long_resp )) != CURLE_OK ) {
435+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_NUM_CONNECTS , & long_resp );
436+ if ( res != CURLE_OK ) {
433437 ELOG_REQ ("CURLINFO_NUM_CONNECTS: %s" , curl_easy_strerror (res ));
434438 } else {
435439 DLOG_REQ ("CURLINFO_NUM_CONNECTS: %d" , long_resp );
@@ -440,20 +444,22 @@ static int https_fetch_ctx_process_response(https_client_t *client,
440444 }
441445
442446 if (logging_debug_enabled ()) {
443- if (( res = curl_easy_getinfo (
444- ctx -> curl , CURLINFO_EFFECTIVE_URL , & str_resp )) != CURLE_OK ) {
447+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_EFFECTIVE_URL , & str_resp );
448+ if ( res != CURLE_OK ) {
445449 ELOG_REQ ("CURLINFO_EFFECTIVE_URL: %s" , curl_easy_strerror (res ));
446450 } else {
447451 DLOG_REQ ("CURLINFO_EFFECTIVE_URL: %s" , str_resp );
448452 }
449- if ((res = curl_easy_getinfo (
450- ctx -> curl , CURLINFO_HTTP_VERSION , & long_resp )) != CURLE_OK ) {
453+
454+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_HTTP_VERSION , & long_resp );
455+ if (res != CURLE_OK ) {
451456 ELOG_REQ ("CURLINFO_HTTP_VERSION: %s" , curl_easy_strerror (res ));
452457 } else if (long_resp != CURL_HTTP_VERSION_NONE ) {
453458 DLOG_REQ ("CURLINFO_HTTP_VERSION: %s" , http_version_str (long_resp ));
454459 }
455- if ((res = curl_easy_getinfo (
456- ctx -> curl , CURLINFO_PROTOCOL , & long_resp )) != CURLE_OK ) {
460+
461+ res = curl_easy_getinfo (ctx -> curl , CURLINFO_PROTOCOL , & long_resp );
462+ if (res != CURLE_OK ) {
457463 ELOG_REQ ("CURLINFO_PROTOCOL: %s" , curl_easy_strerror (res ));
458464 } else if (long_resp != CURLPROTO_HTTPS ) {
459465 DLOG_REQ ("CURLINFO_PROTOCOL: %d" , long_resp );
0 commit comments