From: Francois-Xavier Le Bail Date: Fri, 21 Apr 2023 12:44:55 +0000 (+0200) Subject: Put "}" at beginning of line with "else" to keep a consistent style X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/113ed15b7ecae4a3523454344f9b3438ea97fdc7 Put "}" at beginning of line with "else" to keep a consistent style [skip ci] --- diff --git a/addrtoname.c b/addrtoname.c index b83d1ee2..b60384cb 100644 --- a/addrtoname.c +++ b/addrtoname.c @@ -531,8 +531,7 @@ lookup_nsap(netdissect_options *ndo, const u_char *nsap, k = (ensap[0] << 8) | ensap[1]; j = (ensap[2] << 8) | ensap[3]; i = (ensap[4] << 8) | ensap[5]; - } - else + } else i = j = k = 0; tp = &nsaptable[(i ^ j) & (HASHNAMESIZE-1)]; diff --git a/addrtostr.c b/addrtostr.c index f1ccf797..5a08929a 100644 --- a/addrtostr.c +++ b/addrtostr.c @@ -132,8 +132,7 @@ addrtostr6 (const void *src, char *dst, size_t size) if (cur.base == -1) cur.base = i, cur.len = 1; else cur.len++; - } - else if (cur.base != -1) { + } else if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; cur.base = -1; diff --git a/missing/getopt_long.c b/missing/getopt_long.c index ece00062..e9b1ef57 100644 --- a/missing/getopt_long.c +++ b/missing/getopt_long.c @@ -419,8 +419,7 @@ start: permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; - } - else if (nonopt_start != -1) { + } else if (nonopt_start != -1) { /* * If we skipped non-options, set optind * to the first of them. diff --git a/parsenfsfh.c b/parsenfsfh.c index cd943699..594177c1 100644 --- a/parsenfsfh.c +++ b/parsenfsfh.c @@ -138,8 +138,7 @@ Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len, /* bytes[2,3] == (0,0); must be Auspex */ /* XXX or could be Ultrix+MASSBUS "hp" disk? */ fhtype = FHT_AUSPEX; - } - else { + } else { /* * bytes[2,3] != (0,0); rules out Auspex, could be * DECOSF, SUNOS4, or IRIX4 @@ -148,23 +147,20 @@ Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len, (GET_U_1(fhp + 8) == 12) && (GET_U_1(fhp + 9) == 0)) { /* seems to be DECOSF, with minor == 0 */ fhtype = FHT_DECOSF; - } - else { + } else { /* could be SUNOS4 or IRIX4 */ /* XXX the test of fhp[5] == 8 could be wrong */ if ((GET_U_1(fhp + 4) == 0) && (GET_U_1(fhp + 5) == 8) && (GET_U_1(fhp + 6) == 0) && (GET_U_1(fhp + 7) == 0)) { /* looks like a length, not a file system typecode */ fhtype = FHT_IRIX4; - } - else { + } else { /* by elimination */ fhtype = FHT_SUNOS4; } } } - } - else { + } else { /* * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4 * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5 @@ -183,35 +179,30 @@ Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len, /*XXX we probably only need to test of these two bytes */ else if ((len >= 24/4) && (GET_U_1(fhp + 21) == 0) && (GET_U_1(fhp + 23) == 0)) { fhtype = FHT_ULTRIX; - } - else { + } else { /* Could be SUNOS5/IRIX5, maybe AIX */ /* XXX no obvious difference between SUNOS5 and IRIX5 */ if (GET_U_1(fhp + 9) == 10) fhtype = FHT_SUNOS5; /* XXX what about AIX? */ } - } - else { + } else { /* * bytes[2,3] != (0,0); rules out Ultrix, could be * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX */ if ((GET_U_1(fhp + 8) == 12) && (GET_U_1(fhp + 9) == 0)) { fhtype = FHT_DECOSF; - } - else if ((GET_U_1(fhp + 8) == 0) && (GET_U_1(fhp + 9) == 10)) { + } else if ((GET_U_1(fhp + 8) == 0) && (GET_U_1(fhp + 9) == 10)) { /* could be SUNOS5/IRIX5, AIX, HP-UX */ if ((GET_U_1(fhp + 7) == 0) && (GET_U_1(fhp + 6) == 0) && (GET_U_1(fhp + 5) == 0) && (GET_U_1(fhp + 4) == 0)) { /* XXX is this always true of HP-UX? */ fhtype = FHT_HPUX9; - } - else if (GET_U_1(fhp + 7) == 2) { + } else if (GET_U_1(fhp + 7) == 2) { /* This would be MNT_NFS on AIX, which is impossible */ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */ - } - else { + } else { /* * XXX Could be SUNOS5/IRIX5 or AIX. I don't * XXX see any way to disambiguate these, so @@ -220,12 +211,10 @@ Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len, */ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */ } - } - else { + } else { if (is_UCX(ndo, fhp, len)) { fhtype = FHT_VMSUCX; - } - else { + } else { fhtype = FHT_UNKNOWN; } } @@ -346,8 +335,7 @@ Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len, memset((char *)fsidp, 0, sizeof(*fsidp)); /* just use the whole thing */ memcpy((char *)fsidp, (const char *)fh, 14); - } - else { + } else { uint32_t tempa[4]; /* at least 16 bytes, maybe more */ memset((char *)tempa, 0, sizeof(tempa)); @@ -449,12 +437,10 @@ is_UCX(netdissect_options *ndo, const unsigned char *fhp, u_int len) return(0); else continue; - } - else if (GET_U_1(fhp + i) == 0) { + } else if (GET_U_1(fhp + i) == 0) { seen_null = 1; continue; - } - else + } else return(0); } diff --git a/print-bgp.c b/print-bgp.c index 59b080f2..694346d7 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -3206,8 +3206,7 @@ bgp_notification_print_code(netdissect_options *ndo, /* garbage, hexdump it all */ if (shutdown_comm_length > length - 1) { ND_PRINT(", invalid Shutdown Communication length"); - } - else if (shutdown_comm_length == 0) { + } else if (shutdown_comm_length == 0) { ND_PRINT(", empty Shutdown Communication"); remainder_offset += 1; } diff --git a/print-cdp.c b/print-cdp.c index 0e88929b..c66c0d11 100644 --- a/print-cdp.c +++ b/print-cdp.c @@ -415,8 +415,7 @@ cdp_print_addr(netdissect_options *ndo, ND_PRINT("IPv4 (%u) %s", num, GET_IPADDR_STRING(p)); p += al; l -= al; - } - else if (pt == PT_IEEE_802_2 && pl == 8 && + } else if (pt == PT_IEEE_802_2 && pl == 8 && memcmp(p, prot_ipv6, 8) == 0 && al == 16) { /* * IPv6: protocol type = IEEE 802.2 header, @@ -434,8 +433,7 @@ cdp_print_addr(netdissect_options *ndo, ND_PRINT("IPv6 (%u) %s", num, GET_IP6ADDR_STRING(p)); p += al; l -= al; - } - else { + } else { /* * Generic case: just print raw data */ diff --git a/print-domain.c b/print-domain.c index d2275a5e..d98cd11c 100644 --- a/print-domain.c +++ b/print-domain.c @@ -1070,8 +1070,7 @@ domain_print(netdissect_options *ndo, if (arcount) goto trunc; } - } - else { + } else { /* this is a request */ ND_PRINT("%u%s%s%s", GET_BE_U_2(np->id), ns_ops[DNS_OPCODE(flags)], @@ -1088,8 +1087,7 @@ domain_print(netdissect_options *ndo, ND_PRINT(" [%uq]", qdcount); if (ancount != 1) ND_PRINT(" [%ua]", ancount); - } - else { + } else { if (ancount) ND_PRINT(" [%ua]", ancount); if (qdcount != 1) diff --git a/print-fddi.c b/print-fddi.c index fb8d3ed5..75a1055f 100644 --- a/print-fddi.c +++ b/print-fddi.c @@ -240,8 +240,7 @@ extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst) fdst[i] = fddi_bit_swap[fddip->fddi_dhost[i]]; for (i = 0; i < 6; ++i) fsrc[i] = fddi_bit_swap[fddip->fddi_shost[i]]; - } - else { + } else { memcpy(fdst, (const char *)fddip->fddi_dhost, 6); memcpy(fsrc, (const char *)fddip->fddi_shost, 6); } diff --git a/print-fr.c b/print-fr.c index f0d7fbeb..853dc2f4 100644 --- a/print-fr.c +++ b/print-fr.c @@ -1142,8 +1142,7 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode, dlci = ((GET_U_1(p) & 0x3F) << 4) | ((GET_U_1(p + 1) & 0x78) >> 3); if (ielength == 4) { dlci = (dlci << 6) | ((GET_U_1(p + 2) & 0x7E) >> 1); - } - else if (ielength == 5) { + } else if (ielength == 5) { dlci = (dlci << 13) | (GET_U_1(p + 2) & 0x7F) | ((GET_U_1(p + 3) & 0x7E) >> 1); } diff --git a/print-geneve.c b/print-geneve.c index 364941ad..59dca93e 100644 --- a/print-geneve.c +++ b/print-geneve.c @@ -274,8 +274,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len) if (ndo->ndo_vflag) { if (! geneve_opts_print(ndo, bp, opts_len)) goto invalid; - } - else { + } else { ND_TCHECK_LEN(bp, opts_len); ND_PRINT("%u bytes", opts_len); } diff --git a/print-icmp6.c b/print-icmp6.c index d642f831..ae2596ac 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -1328,8 +1328,7 @@ get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot) if (ND_TTEST_2(uh->uh_dport)) { *prot = nh; return(uh); - } - else + } else return(NULL); /* NOTREACHED */ diff --git a/print-ip.c b/print-ip.c index 23ba99c9..f90c58a0 100644 --- a/print-ip.c +++ b/print-ip.c @@ -363,8 +363,7 @@ ip_print(netdissect_options *ndo, if (len) { ND_PRINT("bad-len %u", len); return; - } - else { + } else { /* we guess that it is a TSO send */ len = length; } diff --git a/print-ldp.c b/print-ldp.c index a62d22ba..0e0194a9 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -364,8 +364,7 @@ ldp_tlv_print(netdissect_options *ndo, ND_PRINT(": IPv4 prefix (invalid length)"); else ND_PRINT(": IPv4 prefix %s", buf); - } - else if (af == AFNUM_IP6) { + } else if (af == AFNUM_IP6) { i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf)); if (i == -2) goto trunc; @@ -375,8 +374,7 @@ ldp_tlv_print(netdissect_options *ndo, ND_PRINT(": IPv6 prefix (invalid length)"); else ND_PRINT(": IPv6 prefix %s", buf); - } - else + } else ND_PRINT(": Address family %u prefix", af); break; case LDP_FEC_HOSTADDRESS: diff --git a/print-mobility.c b/print-mobility.c index 55340ca5..dab853e0 100644 --- a/print-mobility.c +++ b/print-mobility.c @@ -130,8 +130,7 @@ mobility_opt_print(netdissect_options *ndo, else { if (i + 1 < len) { optlen = GET_U_1(bp + i + 1) + 2; - } - else + } else goto trunc; } if (i + optlen > len) diff --git a/print-nfs.c b/print-nfs.c index c90eadbd..8bb4718e 100644 --- a/print-nfs.c +++ b/print-nfs.c @@ -970,8 +970,7 @@ xid_map_enter(netdissect_options *ndo, sizeof(ip->ip_src)); UNALIGNED_MEMCPY(&xmep->server, ip->ip_dst, sizeof(ip->ip_dst)); - } - else if (ip6) { + } else if (ip6) { xmep->ipver = 6; UNALIGNED_MEMCPY(&xmep->client, ip6->ip6_src, sizeof(ip6->ip6_src)); diff --git a/print-nsh.c b/print-nsh.c index 12a63cd6..db78dee6 100644 --- a/print-nsh.c +++ b/print-nsh.c @@ -189,8 +189,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len) bp += NSH_HDR_WORD_SIZE; } past_headers = 1; - } - else if (md_type == MD_TYPE2) { + } else if (md_type == MD_TYPE2) { n = 0; while (n < length - 2) { uint16_t tlv_class; diff --git a/print-olsr.c b/print-olsr.c index 1b0345fc..75acc836 100644 --- a/print-olsr.c +++ b/print-olsr.c @@ -380,8 +380,7 @@ olsr_print(netdissect_options *ndo, msg_tlen = msg_len - sizeof(struct olsr_msg6); msg_data = tptr + sizeof(struct olsr_msg6); - } - else { /* (!is_ipv6) */ + } else { /* (!is_ipv6) */ ND_TCHECK_LEN(tptr, sizeof(struct olsr_msg4)); msgptr.v4 = (const struct olsr_msg4 *) tptr; msg_type = GET_U_1(msgptr.v4->msg_type); @@ -535,8 +534,7 @@ olsr_print(netdissect_options *ndo, msg_data += sizeof(struct olsr_hna6); msg_tlen -= sizeof(struct olsr_hna6); } - } - else { + } else { int col = 0; ND_PRINT("\n\t Advertised networks (total %u)", diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 00c4fdd3..da0b8947 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -1265,8 +1265,7 @@ of10_match_print(netdissect_options *ndo, && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP ? "icmp_code" : "tp_dst"; ND_PRINT("%smatch %s %u", pfx, field_name, GET_BE_U_2(cp)); - } - else + } else ND_TCHECK_2(cp); } diff --git a/print-pim.c b/print-pim.c index cd288e8d..2a33c1ff 100644 --- a/print-pim.c +++ b/print-pim.c @@ -599,8 +599,7 @@ pimv2_addr_print(netdissect_options *ndo, if (af == AFNUM_IP) { if (!silent) ND_PRINT("%s", GET_IPADDR_STRING(bp)); - } - else if (af == AFNUM_IP6) { + } else if (af == AFNUM_IP6) { if (!silent) ND_PRINT("%s", GET_IP6ADDR_STRING(bp)); } @@ -616,8 +615,7 @@ pimv2_addr_print(netdissect_options *ndo, if (GET_U_1(bp + 1) != 32) ND_PRINT("/%u", GET_U_1(bp + 1)); } - } - else if (af == AFNUM_IP6) { + } else if (af == AFNUM_IP6) { if (!silent) { ND_PRINT("%s", GET_IP6ADDR_STRING(bp + 2)); if (GET_U_1(bp + 1) != 128) diff --git a/print-radius.c b/print-radius.c index 1d3ddd60..a15afea6 100644 --- a/print-radius.c +++ b/print-radius.c @@ -916,8 +916,7 @@ print_attr_num(netdissect_options *ndo, ND_PRINT("Tag[%u] ", GET_U_1(data)); data++; data_value = GET_BE_U_3(data); - } - else { + } else { data_value = GET_BE_U_4(data); } if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 + @@ -926,8 +925,7 @@ print_attr_num(netdissect_options *ndo, ND_PRINT("%s", table[data_value]); else ND_PRINT("#%u", data_value); - } - else { + } else { switch(attr_code) /* Be aware of special cases... */ { case FRM_IPX: @@ -1449,8 +1447,7 @@ radius_print(netdissect_options *ndo, GET_U_1(rad->id), len); return; - } - else { + } else { ND_PRINT("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ", len, tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)), diff --git a/print-rpki-rtr.c b/print-rpki-rtr.c index 780845f2..334720f1 100644 --- a/print-rpki-rtr.c +++ b/print-rpki-rtr.c @@ -320,8 +320,7 @@ rpki_rtr_pdu_print(netdissect_options *ndo, const u_char *tptr, const u_int len, goto invalid; if (! recurse) { ND_TCHECK_LEN(tptr, tlen + encapsulated_pdu_length); - } - else { + } else { ND_PRINT("%s-----encapsulated PDU-----", indent_string(indent+4)); rpki_rtr_pdu_print(ndo, tptr + tlen, encapsulated_pdu_length, 0, indent + 2); diff --git a/print-udp.c b/print-udp.c index d036a1fa..bbe5f1cb 100644 --- a/print-udp.c +++ b/print-udp.c @@ -522,8 +522,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length, } else ND_PRINT("[udp sum ok] "); } - } - else if (IP_V(ip) == 6) { + } else if (IP_V(ip) == 6) { /* for IPv6, UDP checksum is mandatory */ if (ND_TTEST_LEN(cp, length)) { sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));