clang-tidy: check `bugprone-macro-parentheses`, fix fallouts
No binary (build failed)
—
(log yok)
| @@ -11,6 +11,7 @@ Checks: | |
| - -clang-analyzer-security.insecureAPI.bzero # for FD_ZERO() (seen on macOS) | |
| - -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling | |
| - -clang-diagnostic-nullability-extension | |
| + | - bugprone-macro-parentheses |
| - bugprone-redundant-branch-condition | |
| - bugprone-suspicious-realloc-usage | |
| - misc-const-correctness | |
| @@ -142,7 +142,7 @@ typedef SOCKET curl_socket_t; | |
| #define CURL_SOCKET_BAD INVALID_SOCKET | |
| #else | |
| typedef int curl_socket_t; | |
| - | #define CURL_SOCKET_BAD -1 |
| + | #define CURL_SOCKET_BAD (-1) |
| #endif | |
| #define curl_socket_typedef | |
| #endif /* curl_socket_typedef */ | |
| @@ -1117,8 +1117,9 @@ typedef CURLSTScode (*curl_hstswrite_callback)(CURL *easy, | |
| /* *STRINGPOINT is an alias for OBJECTPOINT to allow tools to extract the | |
| string options from the header file */ | |
| - | #define CURLOPT(na,t,nu) na = t + nu |
| - | #define CURLOPTDEPRECATED(na,t,nu,v,m) na CURL_DEPRECATED(v,m) = t + nu |
| + | #define CURLOPT(na, t, nu) na = ((t) + (nu)) |
| + | #define CURLOPTDEPRECATED(na, t, nu, v, m) na CURL_DEPRECATED(v, m) \ |
| + | = ((t) + (nu)) |
| /* CURLOPT aliases that make no runtime difference */ | |
| @@ -105,7 +105,7 @@ static void tcpnodelay(struct Curl_cfilter *cf, | |
| (defined(_WIN32) && !defined(TCP_KEEPIDLE)) | |
| /* Solaris < 11.4, DragonFlyBSD < 500702 and Windows < 10.0.16299 | |
| * use millisecond units. */ | |
| - | #define KEEPALIVE_FACTOR(x) (x *= 1000) |
| + | #define KEEPALIVE_FACTOR(x) ((x) *= 1000) |
| #else | |
| #define KEEPALIVE_FACTOR(x) | |
| #endif | |
| @@ -348,7 +348,7 @@ unsigned char Curl_conn_cf_get_transport(struct Curl_cfilter *cf, | |
| const char *Curl_conn_cf_get_alpn_negotiated(struct Curl_cfilter *cf, | |
| struct Curl_easy *data); | |
| - | #define CURL_CF_SSL_DEFAULT -1 |
| + | #define CURL_CF_SSL_DEFAULT (-1) |
| #define CURL_CF_SSL_DISABLE 0 | |
| #define CURL_CF_SSL_ENABLE 1 | |
| @@ -129,7 +129,7 @@ struct SASL { | |
| /* This is used to test whether the line starts with the given mechanism */ | |
| #define sasl_mech_equal(line, wordlen, mech) \ | |
| - | (wordlen == (sizeof(mech) - 1) / sizeof(char) && \ |
| + | ((wordlen) == (sizeof(mech) - 1) / sizeof(char) && \ |
| !memcmp(line, mech, wordlen)) | |
| /* Convert a mechanism name to a token */ | |
| @@ -70,8 +70,8 @@ CURLSHcode Curl_share_lock(struct Curl_easy *, curl_lock_data, | |
| CURLSHcode Curl_share_unlock(struct Curl_easy *, curl_lock_data); | |
| /* convenience macro to check if this handle is using a shared SSL spool */ | |
| - | #define CURL_SHARE_ssl_scache(data) (data->share && \ |
| - | (data->share->specifier & \ |
| + | #define CURL_SHARE_ssl_scache(data) ((data)->share && \ |
| + | ((data)->share->specifier & \ |
| (1 << CURL_LOCK_DATA_SSL_SESSION))) | |
| #endif /* HEADER_CURL_SHARE_H */ | |
| @@ -140,7 +140,7 @@ int curlx_str_singlespace(const char **linep) | |
| /* given an ASCII character and max ascii, return TRUE if valid */ | |
| #define valid_digit(x, m) \ | |
| - | (((x) >= '0') && ((x) <= m) && curlx_hexasciitable[(x) - '0']) |
| + | (((x) >= '0') && ((x) <= (m)) && curlx_hexasciitable[(x) - '0']) |
| /* We use 16 for the zero index (and the necessary bitwise AND in the loop) | |
| to be able to have a non-zero value there to make valid_digit() able to | |
| @@ -78,10 +78,10 @@ | |
| /* macro to check for a three-digit ftp status code at the start of the | |
| given string */ | |
| #define STATUSCODE(line) \ | |
| - | (ISDIGIT(line[0]) && ISDIGIT(line[1]) && ISDIGIT(line[2])) |
| + | (ISDIGIT((line)[0]) && ISDIGIT((line)[1]) && ISDIGIT((line)[2])) |
| /* macro to check for the last line in an FTP server response */ | |
| - | #define LASTLINE(line) (STATUSCODE(line) && (' ' == line[3])) |
| + | #define LASTLINE(line) (STATUSCODE(line) && (' ' == (line)[3])) |
| #ifdef CURLVERBOSE | |
| /* for tracing purposes */ | |
| @@ -379,7 +379,7 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info, | |
| return CURLE_OK; | |
| } | |
| - | #define DOUBLE_SECS(x) (double)(x) / 1000000 |
| + | #define DOUBLE_SECS(x) ((double)(x) / 1000000) |
| static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info, | |
| curl_off_t *param_offt) | |
| @@ -155,7 +155,7 @@ static void hash_elem_link(struct Curl_hash *h, | |
| ++h->size; | |
| } | |
| - | #define CURL_HASH_SLOT(x, y, z) x->table[x->hash_func(y, z, x->slots)] |
| + | #define CURL_HASH_SLOT(x, y, z) x->table[(x)->hash_func(y, z, (x)->slots)] |
| #define CURL_HASH_SLOT_ADDR(x, y, z) &CURL_HASH_SLOT(x, y, z) | |
| void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p, | |
| @@ -3182,11 +3182,11 @@ static statusline checkprotoprefix(struct Curl_easy *data, | |
| /* HTTP header has field name `n` (a string constant) */ | |
| #define HD_IS(hd, hdlen, n) \ | |
| - | (((hdlen) >= (sizeof(n) - 1)) && curl_strnequal((n), (hd), (sizeof(n) - 1))) |
| + | (((hdlen) >= (sizeof(n) - 1)) && curl_strnequal(n, hd, sizeof(n) - 1)) |
| #define HD_VAL(hd, hdlen, n) \ | |
| ((((hdlen) >= (sizeof(n) - 1)) && \ | |
| - | curl_strnequal((n), (hd), (sizeof(n) - 1)))? (hd + (sizeof(n) - 1)) : NULL) |
| + | curl_strnequal(n, hd, sizeof(n) - 1)) ? ((hd) + (sizeof(n) - 1)) : NULL) |
| /* HTTP header has field name `n` (a string constant) and contains `v` | |
| * (a string constant) in its value(s) */ | |
| @@ -260,9 +260,9 @@ static CURLcode cf_h2_update_settings(struct cf_h2_ctx *ctx, | |
| return CURLE_OK; | |
| } | |
| - | #define H2_STREAM_CTX(ctx, data) \ |
| - | ((struct h2_stream_ctx *)( \ |
| - | data? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL)) |
| + | #define H2_STREAM_CTX(ctx, data) \ |
| + | ((struct h2_stream_ctx *)( \ |
| + | (data) ? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL)) |
| static struct h2_stream_ctx *h2_stream_ctx_create(struct cf_h2_ctx *ctx) | |
| { | |
| @@ -38,16 +38,16 @@ | |
| #include <time.h> | |
| - | #define HMAC_SHA256(k, kl, d, dl, o) \ |
| - | do { \ |
| - | result = Curl_hmacit(&Curl_HMAC_SHA256, \ |
| - | (const unsigned char *)k, \ |
| - | kl, \ |
| - | (const unsigned char *)d, \ |
| - | dl, o); \ |
| - | if(result) { \ |
| - | goto fail; \ |
| - | } \ |
| + | #define HMAC_SHA256(k, kl, d, dl, o) \ |
| + | do { \ |
| + | result = Curl_hmacit(&Curl_HMAC_SHA256, \ |
| + | (const unsigned char *)(k), \ |
| + | kl, \ |
| + | (const unsigned char *)(d), \ |
| + | dl, o); \ |
| + | if(result) { \ |
| + | goto fail; \ |
| + | } \ |
| } while(0) | |
| #define TIMESTAMP_SIZE 17 | |
| @@ -37,7 +37,7 @@ | |
| idn2_lookup_u8((const uint8_t *)name, (uint8_t **)host, flags) | |
| #else | |
| #define IDN2_LOOKUP(name, host, flags) \ | |
| - | idn2_lookup_ul((const char *)name, (char **)host, flags) |
| + | idn2_lookup_ul((const char *)(name), (char **)(host), flags) |
| #endif | |
| #endif /* USE_LIBIDN2 */ | |
| @@ -40,7 +40,7 @@ const unsigned char Curl_udigits[] = "0123456789ABCDEF"; | |
| #define OUTCHAR(x) \ | |
| do { \ | |
| - | if(stream((unsigned char)x, userp)) \ |
| + | if(stream((unsigned char)(x), userp)) \ |
| return TRUE; \ | |
| (*donep)++; \ | |
| } while(0) | |
| @@ -145,7 +145,7 @@ static int dollarstring(const char *p, const char **end) | |
| } | |
| #define is_arg_used(x, y) ((x)[(y) / 8] & (1 << ((y) & 7))) | |
| - | #define mark_arg_used(x, y) ((x)[y / 8] |= (unsigned char)(1 << ((y) & 7))) |
| + | #define mark_arg_used(x, y) ((x)[(y) / 8] |= (unsigned char)(1 << ((y) & 7))) |
| /* | |
| * Parse the format string. | |
| @@ -93,7 +93,7 @@ const char * const Curl_month[] = { | |
| #endif | |
| #define PARSEDATE_OK 0 | |
| - | #define PARSEDATE_FAIL -1 |
| + | #define PARSEDATE_FAIL (-1) |
| #ifndef CURL_DISABLE_PARSEDATE | |
| @@ -113,84 +113,84 @@ struct tzinfo { | |
| /* Here's a bunch of frequently used time zone names. These were supported | |
| by the old getdate parser. */ | |
| - | #define tDAYZONE -60 /* offset for daylight savings time */ |
| + | #define tDAYZONE (-60) /* offset for daylight savings time */ |
| static const struct tzinfo tz[] = { | |
| - | { "GMT", 0 }, /* Greenwich Mean */ |
| - | { "UT", 0 }, /* Universal Time */ |
| - | { "UTC", 0 }, /* Universal (Coordinated) */ |
| - | { "WET", 0 }, /* Western European */ |
| - | { "BST", 0 tDAYZONE }, /* British Summer */ |
| - | { "WAT", 60 }, /* West Africa */ |
| - | { "AST", 240 }, /* Atlantic Standard */ |
| - | { "ADT", 240 tDAYZONE }, /* Atlantic Daylight */ |
| - | { "EST", 300 }, /* Eastern Standard */ |
| - | { "EDT", 300 tDAYZONE }, /* Eastern Daylight */ |
| - | { "CST", 360 }, /* Central Standard */ |
| - | { "CDT", 360 tDAYZONE }, /* Central Daylight */ |
| - | { "MST", 420 }, /* Mountain Standard */ |
| - | { "MDT", 420 tDAYZONE }, /* Mountain Daylight */ |
| - | { "PST", 480 }, /* Pacific Standard */ |
| - | { "PDT", 480 tDAYZONE }, /* Pacific Daylight */ |
| - | { "YST", 540 }, /* Yukon Standard */ |
| - | { "YDT", 540 tDAYZONE }, /* Yukon Daylight */ |
| - | { "HST", 600 }, /* Hawaii Standard */ |
| - | { "HDT", 600 tDAYZONE }, /* Hawaii Daylight */ |
| - | { "CAT", 600 }, /* Central Alaska */ |
| - | { "AHST", 600 }, /* Alaska-Hawaii Standard */ |
| - | { "NT", 660 }, /* Nome */ /* spellchecker:disable-line */ |
| - | { "IDLW", 720 }, /* International Date Line West */ |
| - | { "CET", -60 }, /* Central European */ |
| - | { "MET", -60 }, /* Middle European */ |
| - | { "MEWT", -60 }, /* Middle European Winter */ |
| - | { "MEST", -60 tDAYZONE }, /* Middle European Summer */ |
| - | { "CEST", -60 tDAYZONE }, /* Central European Summer */ |
| - | { "MESZ", -60 tDAYZONE }, /* Middle European Summer */ |
| - | { "FWT", -60 }, /* French Winter */ |
| - | { "FST", -60 tDAYZONE }, /* French Summer */ |
| - | { "EET", -120 }, /* Eastern Europe, USSR Zone 1 */ |
| + | { "GMT", 0 }, /* Greenwich Mean */ |
| + | { "UT", 0 }, /* Universal Time */ |
| + | { "UTC", 0 }, /* Universal (Coordinated) */ |
| + | { "WET", 0 }, /* Western European */ |
| + | { "BST", 0 + tDAYZONE }, /* British Summer */ |
| + | { "WAT", 60 }, /* West Africa */ |
| + | { "AST", 240 }, /* Atlantic Standard */ |
| + | { "ADT", 240 + tDAYZONE }, /* Atlantic Daylight */ |
| + | { "EST", 300 }, /* Eastern Standard */ |
| + | { "EDT", 300 + tDAYZONE }, /* Eastern Daylight */ |
| + | { "CST", 360 }, /* Central Standard */ |
| + | { "CDT", 360 + tDAYZONE }, /* Central Daylight */ |
| + | { "MST", 420 }, /* Mountain Standard */ |
| + | { "MDT", 420 + tDAYZONE }, /* Mountain Daylight */ |
| + | { "PST", 480 }, /* Pacific Standard */ |
| + | { "PDT", 480 + tDAYZONE }, /* Pacific Daylight */ |
| + | { "YST", 540 }, /* Yukon Standard */ |
| + | { "YDT", 540 + tDAYZONE }, /* Yukon Daylight */ |
| + | { "HST", 600 }, /* Hawaii Standard */ |
| + | { "HDT", 600 + tDAYZONE }, /* Hawaii Daylight */ |
| + | { "CAT", 600 }, /* Central Alaska */ |
| + | { "AHST", 600 }, /* Alaska-Hawaii Standard */ |
| + | { "NT", 660 }, /* Nome */ /* spellchecker:disable-line */ |
| + | { "IDLW", 720 }, /* International Date Line West */ |
| + | { "CET", -60 }, /* Central European */ |
| + | { "MET", -60 }, /* Middle European */ |
| + | { "MEWT", -60 }, /* Middle European Winter */ |
| + | { "MEST", -60 + tDAYZONE }, /* Middle European Summer */ |
| + | { "CEST", -60 + tDAYZONE }, /* Central European Summer */ |
| + | { "MESZ", -60 + tDAYZONE }, /* Middle European Summer */ |
| + | { "FWT", -60 }, /* French Winter */ |
| + | { "FST", -60 + tDAYZONE }, /* French Summer */ |
| + | { "EET", -120 }, /* Eastern Europe, USSR Zone 1 */ |
| { "WAST", -420 }, /* spellchecker:disable-line */ | |
| - | /* West Australian Standard */ |
| - | { "WADT", -420 tDAYZONE }, /* West Australian Daylight */ |
| - | { "CCT", -480 }, /* China Coast, USSR Zone 7 */ |
| - | { "JST", -540 }, /* Japan Standard, USSR Zone 8 */ |
| - | { "EAST", -600 }, /* Eastern Australian Standard */ |
| - | { "EADT", -600 tDAYZONE }, /* Eastern Australian Daylight */ |
| - | { "GST", -600 }, /* Guam Standard, USSR Zone 9 */ |
| - | { "NZT", -720 }, /* New Zealand */ |
| - | { "NZST", -720 }, /* New Zealand Standard */ |
| - | { "NZDT", -720 tDAYZONE }, /* New Zealand Daylight */ |
| - | { "IDLE", -720 }, /* International Date Line East */ |
| + | /* West Australian Standard */ |
| + | { "WADT", -420 + tDAYZONE }, /* West Australian Daylight */ |
| + | { "CCT", -480 }, /* China Coast, USSR Zone 7 */ |
| + | { "JST", -540 }, /* Japan Standard, USSR Zone 8 */ |
| + | { "EAST", -600 }, /* Eastern Australian Standard */ |
| + | { "EADT", -600 + tDAYZONE }, /* Eastern Australian Daylight */ |
| + | { "GST", -600 }, /* Guam Standard, USSR Zone 9 */ |
| + | { "NZT", -720 }, /* New Zealand */ |
| + | { "NZST", -720 }, /* New Zealand Standard */ |
| + | { "NZDT", -720 + tDAYZONE }, /* New Zealand Daylight */ |
| + | { "IDLE", -720 }, /* International Date Line East */ |
| /* Next up: Military timezone names. RFC822 allowed these, but (as noted in | |
| RFC 1123) had their signs wrong. Here we use the correct signs to match | |
| actual military usage. | |
| */ | |
| - | { "A", 1 * 60 }, /* Alpha */ |
| - | { "B", 2 * 60 }, /* Bravo */ |
| - | { "C", 3 * 60 }, /* Charlie */ |
| - | { "D", 4 * 60 }, /* Delta */ |
| - | { "E", 5 * 60 }, /* Echo */ |
| - | { "F", 6 * 60 }, /* Foxtrot */ |
| - | { "G", 7 * 60 }, /* Golf */ |
| - | { "H", 8 * 60 }, /* Hotel */ |
| - | { "I", 9 * 60 }, /* India */ |
| + | { "A", 1 * 60 }, /* Alpha */ |
| + | { "B", 2 * 60 }, /* Bravo */ |
| + | { "C", 3 * 60 }, /* Charlie */ |
| + | { "D", 4 * 60 }, /* Delta */ |
| + | { "E", 5 * 60 }, /* Echo */ |
| + | { "F", 6 * 60 }, /* Foxtrot */ |
| + | { "G", 7 * 60 }, /* Golf */ |
| + | { "H", 8 * 60 }, /* Hotel */ |
| + | { "I", 9 * 60 }, /* India */ |
| /* "J", Juliet is not used as a timezone, to indicate the observer's local | |
| time */ | |
| - | { "K", 10 * 60 }, /* Kilo */ |
| - | { "L", 11 * 60 }, /* Lima */ |
| - | { "M", 12 * 60 }, /* Mike */ |
| - | { "N", -1 * 60 }, /* November */ |
| - | { "O", -2 * 60 }, /* Oscar */ |
| - | { "P", -3 * 60 }, /* Papa */ |
| - | { "Q", -4 * 60 }, /* Quebec */ |
| - | { "R", -5 * 60 }, /* Romeo */ |
| - | { "S", -6 * 60 }, /* Sierra */ |
| - | { "T", -7 * 60 }, /* Tango */ |
| - | { "U", -8 * 60 }, /* Uniform */ |
| - | { "V", -9 * 60 }, /* Victor */ |
| - | { "W", -10 * 60 }, /* Whiskey */ |
| - | { "X", -11 * 60 }, /* X-ray */ |
| - | { "Y", -12 * 60 }, /* Yankee */ |
| - | { "Z", 0 }, /* Zulu, zero meridian, a.k.a. UTC */ |
| + | { "K", 10 * 60 }, /* Kilo */ |
| + | { "L", 11 * 60 }, /* Lima */ |
| + | { "M", 12 * 60 }, /* Mike */ |
| + | { "N", -1 * 60 }, /* November */ |
| + | { "O", -2 * 60 }, /* Oscar */ |
| + | { "P", -3 * 60 }, /* Papa */ |
| + | { "Q", -4 * 60 }, /* Quebec */ |
| + | { "R", -5 * 60 }, /* Romeo */ |
| + | { "S", -6 * 60 }, /* Sierra */ |
| + | { "T", -7 * 60 }, /* Tango */ |
| + | { "U", -8 * 60 }, /* Uniform */ |
| + | { "V", -9 * 60 }, /* Victor */ |
| + | { "W", -10 * 60 }, /* Whiskey */ |
| + | { "X", -11 * 60 }, /* X-ray */ |
| + | { "Y", -12 * 60 }, /* Yankee */ |
| + | { "Z", 0 }, /* Zulu, zero meridian, a.k.a. UTC */ |
| }; | |
| /* returns: | |
| @@ -189,8 +189,8 @@ static CURLcode setstropt_interface(char *option, char **devp, | |
| } | |
| #ifdef USE_SSL | |
| - | #define C_SSLVERSION_VALUE(x) (x & 0xffff) |
| - | #define C_SSLVERSION_MAX_VALUE(x) ((unsigned long)x & 0xffff0000) |
| + | #define C_SSLVERSION_VALUE(x) ((x) & 0xffff) |
| + | #define C_SSLVERSION_MAX_VALUE(x) ((unsigned long)(x) & 0xffff0000) |
| #endif | |
| static CURLcode protocol2num(const char *str, curl_prot_t *val) | |
| @@ -88,10 +88,10 @@ static CURL_INLINE void sigpipe_apply(struct Curl_easy *data, | |
| #else /* !HAVE_SIGACTION || USE_SO_NOSIGPIPE */ | |
| /* for systems without sigaction or where SO_NOSIGPIPE is used. */ | |
| - | #define sigpipe_ignore(x, y) do { (void)x; (void)y; } while(0) |
| - | #define sigpipe_apply(x, y) do { (void)x; (void)y; } while(0) |
| - | #define sigpipe_init(x) do { (void)x; } while(0) |
| - | #define sigpipe_restore(x) do { (void)x; } while(0) |
| + | #define sigpipe_ignore(x, y) do { (void)(x); (void)(y); } while(0) |
| + | #define sigpipe_apply(x, y) do { (void)(x); (void)(y); } while(0) |
| + | #define sigpipe_init(x) do { (void)(x); } while(0) |
| + | #define sigpipe_restore(x) do { (void)(x); } while(0) |
| struct Curl_sigpipe_ctx { | |
| bool dummy; | |
| @@ -58,20 +58,20 @@ | |
| #define SUBBUFSIZE 512 | |
| - | #define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer |
| - | #define CURL_SB_TERM(x) \ |
| - | do { \ |
| - | x->subend = x->subpointer; \ |
| - | CURL_SB_CLEAR(x); \ |
| + | #define CURL_SB_CLEAR(x) x->subpointer = (x)->subbuffer |
| + | #define CURL_SB_TERM(x) \ |
| + | do { \ |
| + | (x)->subend = (x)->subpointer; \ |
| + | CURL_SB_CLEAR(x); \ |
| } while(0) | |
| - | #define CURL_SB_ACCUM(x, c) \ |
| - | do { \ |
| - | if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \ |
| - | *x->subpointer++ = (c); \ |
| + | #define CURL_SB_ACCUM(x, c) \ |
| + | do { \ |
| + | if((x)->subpointer < ((x)->subbuffer + sizeof((x)->subbuffer))) \ |
| + | *(x)->subpointer++ = (c); \ |
| } while(0) | |
| - | #define CURL_SB_GET(x) ((*x->subpointer++) & 0xff) |
| - | #define CURL_SB_LEN(x) (x->subend - x->subpointer) |
| + | #define CURL_SB_GET(x) ((*(x)->subpointer++) & 0xff) |
| + | #define CURL_SB_LEN(x) ((x)->subend - (x)->subpointer) |
| /* For posterity: | |
| #define CURL_SB_PEEK(x) ((*x->subpointer)&0xff) | |
| @@ -107,7 +107,7 @@ static void uint32_hash_elem_link(struct uint_hash *h, | |
| ++h->size; | |
| } | |
| - | #define CURL_UINT32_HASH_SLOT(h, id) h->table[uint32_hash_hash(id, h->slots)] |
| + | #define CURL_UINT32_HASH_SLOT(h, id) h->table[uint32_hash_hash(id, (h)->slots)] |
| #define CURL_UINT32_HASH_SLOT_ADDR(h, id) &CURL_UINT32_HASH_SLOT(h, id) | |
| bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value) | |
| @@ -1235,7 +1235,7 @@ static bool url_match_auth_nego(struct connectdata *conn, | |
| return TRUE; | |
| } | |
| #else | |
| - | #define url_match_auth_nego(c, m) ((void)c, (void)m, TRUE) |
| + | #define url_match_auth_nego(c, m) ((void)(c), (void)(m), TRUE) |
| #endif | |
| static bool url_match_conn(struct connectdata *conn, void *userdata) | |
| @@ -37,10 +37,10 @@ | |
| #ifdef _WIN32 | |
| /* MS-DOS/Windows style drive prefix, eg c: in c:foo */ | |
| - | #define STARTS_WITH_DRIVE_PREFIX(str) \ |
| - | ((('a' <= str[0] && str[0] <= 'z') || \ |
| - | ('A' <= str[0] && str[0] <= 'Z')) && \ |
| - | (str[1] == ':')) |
| + | #define STARTS_WITH_DRIVE_PREFIX(str) \ |
| + | ((('a' <= (str)[0] && (str)[0] <= 'z') || \ |
| + | ('A' <= (str)[0] && (str)[0] <= 'Z')) && \ |
| + | ((str)[1] == ':')) |
| #endif | |
| /* MS-DOS/Windows style drive prefix, optionally with | |
| @@ -474,7 +474,7 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname, | |
| * Returns the host type. | |
| */ | |
| - | #define HOST_ERROR -1 /* out of memory */ |
| + | #define HOST_ERROR (-1) /* out of memory */ |
| #define HOST_NAME 1 | |
| #define HOST_IPV4 2 | |
| @@ -1300,9 +1300,9 @@ void curl_url_cleanup(CURLU *u) | |
| #define DUP(dest, src, name) \ | |
| do { \ | |
| - | if(src->name) { \ |
| - | dest->name = curlx_strdup(src->name); \ |
| - | if(!dest->name) \ |
| + | if((src)->name) { \ |
| + | (dest)->name = curlx_strdup((src)->name); \ |
| + | if(!(dest)->name) \ |
| goto fail; \ | |
| } \ | |
| } while(0) | |
| @@ -328,7 +328,7 @@ typedef enum { | |
| #ifdef CURL_DISABLE_PROXY | |
| #define CONN_IS_PROXIED(x) 0 | |
| #else | |
| - | #define CONN_IS_PROXIED(x) x->bits.proxy |
| + | #define CONN_IS_PROXIED(x) (x)->bits.proxy |
| #endif | |
| /* | |
| @@ -29,9 +29,9 @@ | |
| #include "tool_operate.h" | |
| #ifdef _WIN32 | |
| - | #define OPENMODE _S_IREAD | _S_IWRITE |
| + | #define OPENMODE (_S_IREAD | _S_IWRITE) |
| #else | |
| - | #define OPENMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH |
| + | #define OPENMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) |
| #endif | |
| /* create/open a local file for writing, return TRUE on success */ | |
| @@ -33,7 +33,7 @@ | |
| /* only acknowledge colon or equals as separators if the option was not | |
| specified with an initial dash! */ | |
| - | #define ISSEP(x, dash) (!dash && (((x) == '=') || ((x) == ':'))) |
| + | #define ISSEP(x, dash) (!(dash) && (((x) == '=') || ((x) == ':'))) |
| /* | |
| * Copies the string from line to the param dynbuf, unquoting backslash-quoted | |
| @@ -175,7 +175,7 @@ static const struct NameValue setopt_nv_CURLNONZERODEFAULTS[] = { | |
| /* Escape string to C string syntax. Return NULL if out of memory. */ | |
| #define MAX_STRING_LENGTH_OUTPUT 2000 | |
| - | #define ZERO_TERMINATED -1 |
| + | #define ZERO_TERMINATED (-1) |
| static char *c_escape(const char *str, curl_off_t len) | |
| { | |
| @@ -134,7 +134,7 @@ CURLcode tool_setopt_ptr(CURL *curl, const char *name, CURLoption tag, ...); | |
| #define my_setopt_slist(x, y, z) curl_easy_setopt(x, y, z) | |
| #define my_setopt_SSLVERSION(x, y, z) curl_easy_setopt(x, y, z) | |
| #define my_setopt_enum(x, y, z) curl_easy_setopt(x, y, z) | |
| - | #define my_setopt_bitmask(x, y, z) curl_easy_setopt(x, y, (long)z) |
| + | #define my_setopt_bitmask(x, y, z) curl_easy_setopt(x, y, (long)(z)) |
| #define MY_SETOPT_STR(x, y, z) \ | |
| do { \ | |
| @@ -40,8 +40,11 @@ void vms_special_exit(int code, int vms_show); | |
| #undef exit | |
| #define exit(__code) vms_special_exit(__code, 0) | |
| - | #define VMS_STS(c, f, e, s) \ |
| - | (((c & 0xF) << 28) | ((f & 0xFFF) << 16) | ((e & 0x1FFF) < 3) | (s & 7)) |
| + | #define VMS_STS(c, f, e, s) \ |
| + | ((((c) & 0xF) << 28) | \ |
| + | (((f) & 0xFFF) << 16) | \ |
| + | (((e) & 0x1FFF) < 3) | \ |
| + | ((s) & 7)) |
| #define VMSSTS_HIDE VMS_STS(1, 0, 0, 0) | |
| #endif /* __VMS */ | |
| @@ -59,7 +59,7 @@ static const struct tool_var *varcontent(const char *name, size_t nlen) | |
| #define ENDOFFUNC(x) (((x) == '}') || ((x) == ':')) | |
| #define FUNCMATCH(ptr, name, len) \ | |
| - | (!strncmp(ptr, name, len) && ENDOFFUNC(ptr[len])) |
| + | (!strncmp(ptr, name, len) && ENDOFFUNC((ptr)[len])) |
| #define FUNC_TRIM "trim" | |
| #define FUNC_TRIM_LEN (sizeof(FUNC_TRIM) - 1) | |
| @@ -149,7 +149,7 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define exe_easy_init(A, Y, Z) \ | |
| do { \ | |
| - | A = curl_easy_init(); \ |
| + | (A) = curl_easy_init(); \ |
| if(!(A)) { \ | |
| curl_mfprintf(stderr, "%s:%d curl_easy_init() failed\n", Y, Z); \ | |
| result = TEST_ERR_EASY_INIT; \ | |
| @@ -173,7 +173,7 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define exe_multi_init(A, Y, Z) \ | |
| do { \ | |
| - | A = curl_multi_init(); \ |
| + | (A) = curl_multi_init(); \ |
| if(!(A)) { \ | |
| curl_mfprintf(stderr, "%s:%d curl_multi_init() failed\n", Y, Z); \ | |
| result = TEST_ERR_MULTI; \ | |
| @@ -499,7 +499,7 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| tv_test_start = curlx_now(); \ | |
| } while(0) | |
| - | #define TEST_HANG_TIMEOUT 60 * 1000 /* global default */ |
| + | #define TEST_HANG_TIMEOUT (60 * 1000) /* global default */ |
| #define exe_test_timedout(T, Y, Z) \ | |
| do { \ | |
| @@ -508,7 +508,7 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| curl_mfprintf(stderr, \ | |
| "%s:%d ABORTING TEST, since it seems " \ | |
| "that it would have run forever (%ld ms > %ld ms)\n", \ | |
| - | Y, Z, (long)timediff, (long)(TEST_HANG_TIMEOUT)); \ |
| + | Y, Z, (long)timediff, (long)TEST_HANG_TIMEOUT); \ |
| result = TEST_ERR_RUNS_FOREVER; \ | |
| } \ | |
| } while(0) | |
| @@ -46,7 +46,7 @@ | |
| curl_mfprintf(stderr, "test failed with code: %d\n", result); \ | |
| goto test_cleanup; \ | |
| } \ | |
| - | else if(fd_count != expected_fds) { \ |
| + | else if(fd_count != (expected_fds)) { \ |
| curl_mfprintf(stderr, "Max number of waitfds: %u not as expected: %u\n", \ | |
| fd_count, expected_fds); \ | |
| result = TEST_ERR_FAILURE; \ | |
| @@ -1322,7 +1322,7 @@ static int test_weird_arguments(void) | |
| } | |
| /* DBL_MAX value from Linux */ | |
| - | #define MAXIMIZE -1.7976931348623157081452E+308 |
| + | #define MAXIMIZE (-1.7976931348623157081452E+308) |
| static int test_float_formatting(void) | |
| { | |
| @@ -214,9 +214,9 @@ struct t1521_testdata { | |
| #define LO $minlong | |
| #define HI $maxlong | |
| - | #define OFF_LO (curl_off_t) LO |
| - | #define OFF_HI (curl_off_t) $maxofft |
| - | #define OFF_NO (curl_off_t) 0 |
| + | #define OFF_LO ((curl_off_t)(LO)) |
| + | #define OFF_HI ((curl_off_t)($maxofft)) |
| + | #define OFF_NO ((curl_off_t)0) |
| static size_t writecb(char *buffer, size_t size, size_t nitems, | |
| void *outstream) | |
| @@ -345,7 +345,9 @@ static bool bad_neg(int check) | |
| /* macro to check the first setopt of an option which then is allowed to get a | |
| non-existing function return code back */ | |
| - | #define present(x) ((x != CURLE_NOT_BUILT_IN) && (x != CURLE_UNKNOWN_OPTION)) |
| + | #define present(x) \\ |
| + | (((x) != CURLE_NOT_BUILT_IN) && \\ |
| + | ((x) != CURLE_UNKNOWN_OPTION)) |
| static CURLcode test_lib1521(const char *URL) | |
| { | |
| @@ -44,12 +44,12 @@ | |
| #define verify_memory(dynamic, check, len) \ | |
| do { \ | |
| - | if(dynamic && memcmp(dynamic, check, len)) { \ |
| + | if((dynamic) && memcmp(dynamic, check, len)) { \ |
| curl_mfprintf(stderr, "%s:%d Memory buffer FAILED match size %d. " \ | |
| "'%s' is not\n", __FILE__, __LINE__, len, \ | |
| - | hexdump((const unsigned char *)check, len)); \ |
| + | hexdump((const unsigned char *)(check), len)); \ |
| curl_mfprintf(stderr, "%s:%d the same as '%s'\n", __FILE__, __LINE__, \ | |
| - | hexdump((const unsigned char *)dynamic, len)); \ |
| + | hexdump((const unsigned char *)(dynamic), len)); \ |
| unitfail++; \ | |
| } \ | |
| } while(0) | |
| @@ -116,5 +116,5 @@ unit_test_abort: \ | |
| goto unit_test_abort; /* avoid warning */ \ | |
| } \ | |
| unit_test_abort: \ | |
| - | stopfunc; \ |
| + | (stopfunc); \ |
| return (CURLcode)unitfail; | |
| @@ -112,8 +112,8 @@ typedef union { | |
| } srvr_sockaddr_union_t; | |
| /* getpart */ | |
| - | #define GPE_NO_BUFFER_SPACE -2 |
| - | #define GPE_OUT_OF_MEMORY -1 |
| + | #define GPE_NO_BUFFER_SPACE (-2) |
| + | #define GPE_OUT_OF_MEMORY (-1) |
| #define GPE_OK 0 | |
| #define GPE_END_OF_FILE 1 | |
| @@ -146,8 +146,8 @@ struct bf { | |
| tftphdr_storage_t buf; /* room for data packet */ | |
| }; | |
| - | #define BF_ALLOC -3 /* allocated but not yet filled */ |
| - | #define BF_FREE -2 /* free */ |
| + | #define BF_ALLOC (-3) /* allocated but not yet filled */ |
| + | #define BF_FREE (-2) /* free */ |
| #define opcode_RRQ 1 | |
| #define opcode_WRQ 2 | |