From: Francois-Xavier Le Bail Date: Tue, 6 Feb 2018 18:15:45 +0000 (+0100) Subject: Style update X-Git-Tag: tcpdump-4.99-bp~1286 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/46f5203a8d1a05e464b5138b512d81a86dca6517 Style update Use parens around the sizeof argument, to match the style used elsewhere. --- diff --git a/print-802_11.c b/print-802_11.c index b211a55a..f761d494 100644 --- a/print-802_11.c +++ b/print-802_11.c @@ -826,7 +826,7 @@ static const float ieee80211_float_htrates[MAX_MCS_INDEX+1][2][2] = { }; static const char *auth_alg_text[]={"Open System","Shared Key","EAP"}; -#define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0]) +#define NUM_AUTH_ALGS (sizeof(auth_alg_text) / sizeof(auth_alg_text[0])) static const char *status_text[] = { "Successful", /* 0 */ @@ -908,7 +908,7 @@ static const char *status_text[] = { "The Destination STA is not a QSTA.", /* 50 */ }; -#define NUM_STATUSES (sizeof status_text / sizeof status_text[0]) +#define NUM_STATUSES (sizeof(status_text) / sizeof(status_text[0])) static const char *reason_text[] = { "Reserved", /* 0 */ @@ -976,7 +976,7 @@ static const char *reason_text[] = { "Association denied due to requesting STA not supporting HT " "features", /* 46 */ }; -#define NUM_REASONS (sizeof reason_text / sizeof reason_text[0]) +#define NUM_REASONS (sizeof(reason_text) / sizeof(reason_text[0])) static int wep_print(netdissect_options *ndo, @@ -1087,7 +1087,7 @@ parse_elements(netdissect_options *ndo, offset += 2; length -= 2; if (rates.length != 0) { - if (rates.length > sizeof rates.rate) + if (rates.length > sizeof(rates.rate)) return 0; memcpy(&rates.rate, p + offset, rates.length); offset += rates.length; @@ -1171,7 +1171,7 @@ parse_elements(netdissect_options *ndo, length -= tim.length; break; } - if (tim.length - 3U > sizeof tim.bitmap) + if (tim.length - 3U > sizeof(tim.bitmap)) return 0; memcpy(&tim.count, p + offset, 3); offset += 3; diff --git a/print-bootp.c b/print-bootp.c index cbbac30d..c62785b0 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -360,7 +360,7 @@ bootp_print(netdissect_options *ndo, ND_TCHECK_1(bp->bp_sname); /* check first char only */ if (EXTRACT_U_1(bp->bp_sname)) { ND_PRINT("\n\t sname \""); - if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname, + if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof(bp->bp_sname), ndo->ndo_snapend)) { ND_PRINT("\""); ND_PRINT("%s", tstr + 1); @@ -371,7 +371,7 @@ bootp_print(netdissect_options *ndo, ND_TCHECK_1(bp->bp_file); /* check first char only */ if (EXTRACT_U_1(bp->bp_file)) { ND_PRINT("\n\t file \""); - if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file, + if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof(bp->bp_file), ndo->ndo_snapend)) { ND_PRINT("\""); ND_PRINT("%s", tstr + 1); diff --git a/print-isoclns.c b/print-isoclns.c index e5de4ab1..bcd8e884 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -2166,7 +2166,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo, if (!ND_TTEST_LEN(tptr, byte_length)) return (0); - memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ + memset(prefix, 0, sizeof(prefix)); /* clear the copy buffer */ memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ tptr+=byte_length; processed+=byte_length; diff --git a/print-ppp.c b/print-ppp.c index de17538a..180f8d60 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -213,7 +213,7 @@ static const char *lcpconfopts[] = { "PPP-Muxing", /* (30) */ }; -#define NUM_LCPOPTS (sizeof lcpconfopts / sizeof lcpconfopts[0]) +#define NUM_LCPOPTS (sizeof(lcpconfopts) / sizeof(lcpconfopts[0])) /* ECP - to be supported */ diff --git a/print-tcp.c b/print-tcp.c index 554f8a61..41392f99 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -267,16 +267,16 @@ tcp_print(netdissect_options *ndo, if (sport > dport) rev = 1; else if (sport == dport) { - if (UNALIGNED_MEMCMP(src, dst, sizeof ip6->ip6_dst) > 0) + if (UNALIGNED_MEMCMP(src, dst, sizeof(ip6->ip6_dst)) > 0) rev = 1; } if (rev) { - UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip6->ip6_dst); - UNALIGNED_MEMCPY(&tha.dst, src, sizeof ip6->ip6_src); + UNALIGNED_MEMCPY(&tha.src, dst, sizeof(ip6->ip6_dst)); + UNALIGNED_MEMCPY(&tha.dst, src, sizeof(ip6->ip6_src)); tha.port = dport << 16 | sport; } else { - UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip6->ip6_dst); - UNALIGNED_MEMCPY(&tha.src, src, sizeof ip6->ip6_src); + UNALIGNED_MEMCPY(&tha.dst, dst, sizeof(ip6->ip6_dst)); + UNALIGNED_MEMCPY(&tha.src, src, sizeof(ip6->ip6_src)); tha.port = sport << 16 | dport; } @@ -318,20 +318,20 @@ tcp_print(netdissect_options *ndo, if (sport > dport) rev = 1; else if (sport == dport) { - if (UNALIGNED_MEMCMP(ip->ip_src, ip->ip_dst, sizeof ip->ip_dst) > 0) + if (UNALIGNED_MEMCMP(ip->ip_src, ip->ip_dst, sizeof(ip->ip_dst)) > 0) rev = 1; } if (rev) { UNALIGNED_MEMCPY(&tha.src, ip->ip_dst, - sizeof ip->ip_dst); + sizeof(ip->ip_dst)); UNALIGNED_MEMCPY(&tha.dst, ip->ip_src, - sizeof ip->ip_src); + sizeof(ip->ip_src)); tha.port = dport << 16 | sport; } else { UNALIGNED_MEMCPY(&tha.dst, ip->ip_dst, - sizeof ip->ip_dst); + sizeof(ip->ip_dst)); UNALIGNED_MEMCPY(&tha.src, ip->ip_src, - sizeof ip->ip_src); + sizeof(ip->ip_src)); tha.port = sport << 16 | dport; } diff --git a/signature.c b/signature.c index 466af01f..6f624428 100644 --- a/signature.c +++ b/signature.c @@ -81,8 +81,8 @@ signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key */ /* start out by storing key in pads */ - memset(k_ipad, 0, sizeof k_ipad); - memset(k_opad, 0, sizeof k_opad); + memset(k_ipad, 0, sizeof(k_ipad)); + memset(k_opad, 0, sizeof(k_opad)); memcpy(k_ipad, key, key_len); memcpy(k_opad, key, key_len); diff --git a/tcpdump.c b/tcpdump.c index 81321f79..f0505fe2 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1327,7 +1327,7 @@ main(int argc, char **argv) /* * Initialize the netdissect code. */ - if (nd_init(ebuf, sizeof ebuf) == -1) + if (nd_init(ebuf, sizeof(ebuf)) == -1) error("%s", ebuf); memset(ndo, 0, sizeof(*ndo)); @@ -1528,7 +1528,7 @@ main(int argc, char **argv) case 'm': if (nd_have_smi_support()) { - if (nd_load_smi_module(optarg, ebuf, sizeof ebuf) == -1) + if (nd_load_smi_module(optarg, ebuf, sizeof(ebuf)) == -1) error("%s", ebuf); } else { (void)fprintf(stderr, "%s: ignoring option `-m %s' ",