From beaca3e8dbdafcf7474ff07c8f95116919367ac2 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Mon, 9 Mar 2020 18:23:13 -0700 Subject: [PATCH] remove or comment empty conditional branches some empty conditional branches which contained a semicolon were "fixed" by clang-format to contain nothing. add comments to prevent this. (cherry picked from commit 735be3b816913f8fae3153366ec89e5511ff52b4) --- bin/named/zoneconf.c | 4 ++-- lib/dns/rdata/in_1/wks_11.c | 39 ++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 6a28cf83ae..e01b095bb4 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -1442,7 +1442,7 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(arg, "maintain") == 0) { allow = maint = true; } else if (strcasecmp(arg, "off") == 0) { - ; + /* Default */ } else { INSIST(0); ISC_UNREACHABLE(); @@ -1591,7 +1591,7 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, dns_zone_setkeyopt(zone, DNS_ZONEKEY_NORESIGN, true); } else if (strcasecmp(arg, "maintain") == 0) { - ; + /* Default */ } else { INSIST(0); ISC_UNREACHABLE(); diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 8ad0bf6ea1..ed77c2f2d0 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -73,7 +73,7 @@ fromtext_in_wks(ARGS_FROMTEXT) { isc_token_t token; isc_region_t region; struct in_addr addr; - char *e; + char *e = NULL; long proto; unsigned char bm[8*1024]; /* 64k bits */ long port; @@ -115,10 +115,12 @@ fromtext_in_wks(ARGS_FROMTEXT) { false)); isc_buffer_availableregion(target, ®ion); - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) + if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) { CHECKTOK(DNS_R_BADDOTTEDQUAD); - if (region.length < 4) + } + if (region.length < 4) { return (ISC_R_NOSPACE); + } memmove(region.base, &addr, 4); isc_buffer_add(target, 4); @@ -129,18 +131,19 @@ fromtext_in_wks(ARGS_FROMTEXT) { false)); proto = strtol(DNS_AS_STR(token), &e, 10); - if (*e == 0) - ; - else if (!mygetprotobyname(DNS_AS_STR(token), &proto)) + if (*e != '\0' && !mygetprotobyname(DNS_AS_STR(token), &proto)) { CHECKTOK(DNS_R_UNKNOWNPROTO); + } - if (proto < 0 || proto > 0xff) + if (proto < 0 || proto > 0xff) { CHECKTOK(ISC_R_RANGE); + } - if (proto == IPPROTO_TCP) + if (proto == IPPROTO_TCP) { ps = "tcp"; - else if (proto == IPPROTO_UDP) + } else if (proto == IPPROTO_UDP) { ps = "udp"; + } CHECK(uint8_tobuffer(proto, target)); @@ -148,8 +151,9 @@ fromtext_in_wks(ARGS_FROMTEXT) { do { CHECK(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, true)); - if (token.type != isc_tokentype_string) + if (token.type != isc_tokentype_string) { break; + } /* * Lowercase the service string as some getservbyname() are @@ -161,15 +165,18 @@ fromtext_in_wks(ARGS_FROMTEXT) { service[i] = tolower(service[i]&0xff); port = strtol(DNS_AS_STR(token), &e, 10); - if (*e == 0) - ; - else if (!mygetservbyname(service, ps, &port) && - !mygetservbyname(DNS_AS_STR(token), ps, &port)) + if (*e != 0 && !mygetservbyname(service, ps, &port) && + !mygetservbyname(DNS_AS_STR(token), ps, &port)) + { CHECKTOK(DNS_R_UNKNOWNSERVICE); - if (port < 0 || port > 0xffff) + } + + if (port < 0 || port > 0xffff) { CHECKTOK(ISC_R_RANGE); - if (port > maxport) + } + if (port > maxport) { maxport = port; + } bm[port / 8] |= (0x80 >> (port % 8)); } while (1);