]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Address various E_STATEMENT_NOT_REACHED from Sun C.
authorDenis Ovsienko <[email protected]>
Thu, 14 Mar 2024 20:42:44 +0000 (20:42 +0000)
committerGuy Harris <[email protected]>
Fri, 15 Mar 2024 07:08:55 +0000 (00:08 -0700)
Most of the unreachable statements are as plain as break after return,
but one is a bit less obvious.  Rearrange a few comments for clarity.

cc: Studio 12.6 Sun C 5.15 SunOS_i386 2017/05/30

"./tcpdump.c", line 1743: warning: statement not reached
"./tcpdump.c", line 1991: warning: statement not reached
"./tcpdump.c", line 2071: warning: statement not reached
"./print-802_15_4.c", line 516: warning: statement not reached
"./print-802_15_4.c", line 523: warning: statement not reached
"./print-802_15_4.c", line 526: warning: statement not reached
"./print-802_15_4.c", line 529: warning: statement not reached
"./print-802_15_4.c", line 1392: warning: statement not reached
"./print-802_15_4.c", line 1557: warning: statement not reached
"./print-802_15_4.c", line 1635: warning: statement not reached
"./print-802_15_4.c", line 1666: warning: statement not reached
"./print-802_15_4.c", line 1726: warning: statement not reached
"./print-802_15_4.c", line 1743: warning: statement not reached
"./print-802_15_4.c", line 2496: warning: statement not reached
"./print-802_15_4.c", line 2499: warning: statement not reached
"./print-802_15_4.c", line 2502: warning: statement not reached
"./print-802_15_4.c", line 2505: warning: statement not reached
"./print-802_15_4.c", line 2508: warning: statement not reached
"./print-bgp.c", line 2253: warning: statement not reached
"./print-dccp.c", line 395: warning: statement not reached
"./print-dccp.c", line 599: warning: statement not reached
"./print-juniper.c", line 1169: warning: statement not reached
"./print-juniper.c", line 1213: warning: statement not reached
"./print-lisp.c", line 323: warning: statement not reached
"./print-mobility.c", line 322: warning: statement not reached
"./print-pgm.c", line 277: warning: statement not reached
"./print-pgm.c", line 309: warning: statement not reached
"./print-pgm.c", line 387: warning: statement not reached
"./print-pgm.c", line 408: warning: statement not reached
"./print-pgm.c", line 633: warning: statement not reached
"./print-pgm.c", line 790: warning: statement not reached
"./print-pgm.c", line 833: warning: statement not reached
"./print-pim.c", line 587: warning: statement not reached
"./print-pim.c", line 816: warning: statement not reached
"./print-resp.c", line 263: warning: statement not reached
"./print-resp.c", line 313: warning: statement not reached
"./print-rt6.c", line 168: warning: statement not reached
"./print-rt6.c", line 198: warning: statement not reached
"./smbutil.c", line 894: warning: statement not reached

12 files changed:
print-802_15_4.c
print-bgp.c
print-dccp.c
print-juniper.c
print-lisp.c
print-mobility.c
print-pgm.c
print-pim.c
print-resp.c
print-rt6.c
smbutil.c
tcpdump.c

index 40baef1a63be04228e794d729b6cf2c0a4767e54..c255212c58987ac6f9e0c128a00f3410f290af64 100644 (file)
@@ -513,20 +513,16 @@ ieee802_15_4_addr_len(uint16_t addr_type)
        switch (addr_type) {
        case FC_ADDRESSING_MODE_NONE: /* None. */
                return 0;
-               break;
        case FC_ADDRESSING_MODE_RESERVED: /* Reserved, there used to be 8-bit
                                           * address type in one amendment, but
                                           * that and the feature using it was
                                           * removed during 802.15.4-2015
                                           * maintenance process. */
                return -1;
-               break;
        case FC_ADDRESSING_MODE_SHORT: /* Short. */
                return 2;
-               break;
        case FC_ADDRESSING_MODE_LONG: /* Extended. */
                return 8;
-               break;
        }
        return 0;
 }
@@ -1388,8 +1384,6 @@ ieee802_15_4_print_mpx_ie(netdissect_options *ndo,
                        }
                }
                return;
-               /* NOTREACHED */
-               break;
        case 0x03: /* Reserved */
        case 0x05: /* Reserved */
        case 0x07: /* Reserved */
@@ -1554,7 +1548,6 @@ ieee802_15_4_print_aux_sec_header(netdissect_options *ndo,
                        ND_PRINT("Implicit");
                }
                return len;
-               break;
        case 0x01: /* Key Index, nothing to print here. */
                break;
        case 0x02: /* PAN and Short address Key Source, and Key Index. */
@@ -1632,7 +1625,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
                                  "Allocate address, " : ""));
                        return caplen;
                }
-               break;
+               /* NOTREACHED */
        case 0x02: /* Association Response */
                if (caplen != 3) {
                        ND_PRINT("Invalid Association response command length");
@@ -1663,7 +1656,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
                        }
                        return caplen;
                }
-               break;
+               /* NOTREACHED */
        case 0x03: /* Disassociation Notification command */
                if (caplen != 1) {
                        ND_PRINT("Invalid Disassociation Notification command length");
@@ -1723,7 +1716,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
                        ieee802_15_4_print_addr(ndo, p + 5, 2);
                        return caplen;
                }
-               break;
+               /* NOTREACHED */
        case 0x09: /* GTS Request command */
                if (caplen != 1) {
                        ND_PRINT("Invalid GTS Request command length");
@@ -1740,7 +1733,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
                                  "GTS allocation" : "GTS deallocations"));
                        return caplen;
                }
-               break;
+               /* NOTREACHED */
        case 0x13: /* DSME Association Request command */
                /* XXX Not implemented */
        case 0x14: /* DSME Association Response command */
@@ -2493,19 +2486,14 @@ ieee802_15_4_print(netdissect_options *ndo,
        case 0x02: /* Acknowledgement */
        case 0x03: /* MAC Command */
                return ieee802_15_4_std_frames(ndo, p, caplen, fc);
-               break;
        case 0x04: /* Reserved */
                return 0;
-               break;
        case 0x05: /* Multipurpose */
                return ieee802_15_4_mp_frame(ndo, p, caplen, fc);
-               break;
        case 0x06: /* Fragment or Frak */
                return ieee802_15_4_frag_frame(ndo, p, caplen, fc);
-               break;
        case 0x07: /* Extended */
                return 0;
-               break;
        }
        return 0;
 }
index b842b72eda4be17a672e837abe2278f9b366f44f..8f319f85dca8a1b3dd18a1de870f29d1800dece2 100644 (file)
@@ -2250,7 +2250,6 @@ bgp_attr_print(netdissect_options *ndo,
                     tlen -= tnhlen;
                     tnhlen = 0;
                     goto done;
-                    break;
                 }
             }
         }
index 5a0890a9a481923ca5b423ac1665593be9cc66eb..4c5d4e297743037969ecc3484e39deac4875ef53 100644 (file)
@@ -392,7 +392,6 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                break;
        default:
                goto invalid;
-               break;
        }
 
        if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
@@ -596,7 +595,6 @@ dccp_print_option(netdissect_options *ndo, const u_char *bp, u_int hlen)
                        default:
                                ND_PRINT(" [optlen != 6 or 8 or 10]");
                                goto invalid;
-                               break;
                        }
                        break;
                case DCCP_OPTION_ELAPSED_TIME:
index 05ff2f4ab6bd73e6817604baa28a6d9448514cba..3dda8598ccdb2abea3e6c386a8b1c288ada77073 100644 (file)
@@ -1166,7 +1166,6 @@ juniper_ppp_heuristic_guess(netdissect_options *ndo,
 
     default:
         return 0; /* did not find a ppp header */
-        break;
     }
     return 1; /* we printed a ppp packet */
 }
@@ -1210,7 +1209,6 @@ ip_heuristic_guess(netdissect_options *ndo,
         break;
     default:
         return 0; /* did not find a ip header */
-        break;
     }
     return 1; /* we printed an v4/v6 packet */
 }
index ae90f4e5c961d1ca511143bb547decaa460849a5..cb939c3a5996787327600566126250165f5b63a9 100644 (file)
@@ -320,7 +320,6 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                         * No support for LCAF right now.
                         */
                        return;
-                       break;
                }
 
                ND_PRINT(" %u locator(s)", loc_count);
index dab853e05c92c4b0ea38023c278208433ee5b056..9decad75fe10484f326e04142cca5412e77c5b62 100644 (file)
@@ -319,7 +319,6 @@ mobility_print(netdissect_options *ndo,
        default:
                ND_PRINT(" len=%u", GET_U_1(mh->ip6m_len));
                return(mhlen);
-               break;
        }
        if (ndo->ndo_vflag)
                if (mobility_opt_print(ndo, bp + hlen, mhlen - hlen))
index b0ef9e4c2bbc2d95f121607e3ac00458577937c6..e37d3fdaf195e6fa1df9bb21b400a7b8fdadc986 100644 (file)
@@ -274,7 +274,6 @@ pgm_print(netdissect_options *ndo,
                break;
            default:
                goto invalid;
-               break;
            }
 
            ND_PRINT("SPM seq %u trail %u lead %u nla %s",
@@ -306,7 +305,6 @@ pgm_print(netdissect_options *ndo,
                break;
            default:
                goto invalid;
-               break;
            }
 
            ivl = GET_BE_U_4(bp);
@@ -384,7 +382,6 @@ pgm_print(netdissect_options *ndo,
                break;
            default:
                goto invalid;
-               break;
            }
 
            /*
@@ -405,7 +402,6 @@ pgm_print(netdissect_options *ndo,
                break;
            default:
                goto invalid;
-               break;
            }
 
            /*
@@ -630,7 +626,6 @@ pgm_print(netdissect_options *ndo,
                        break;
                    default:
                        goto invalid;
-                       break;
                    }
 
                    ND_PRINT(" REDIRECT %s",  nla_buf);
@@ -787,7 +782,6 @@ pgm_print(netdissect_options *ndo,
                        break;
                    default:
                        goto invalid;
-                       break;
                    }
 
                    ND_PRINT(" PGMCC DATA %u %s", offset, nla_buf);
@@ -830,7 +824,6 @@ pgm_print(netdissect_options *ndo,
                        break;
                    default:
                        goto invalid;
-                       break;
                    }
 
                    ND_PRINT(" PGMCC FEEDBACK %u %s", offset, nla_buf);
index 70948cdad5a9883c8026a60695a41e6505c804c5..71d78e3dd0c16f1ca32f71789f46827ac4a43973 100644 (file)
@@ -584,7 +584,6 @@ pimv2_addr_print(netdissect_options *ndo,
                        break;
                default:
                        return -1;
-                       break;
                }
                hdrlen = 0;
        }
@@ -813,7 +812,6 @@ pimv2_print(netdissect_options *ndo,
                                        ND_PRINT("[option length %u != 4]", olen);
                                        nd_print_invalid(ndo);
                                        return;
-                                       break;
                                }
                                break;
 
index db2f1d17e1e855e729b31b7156cba4b519026c63..57e068dad89e3fba6d5eed3175f153f3a543834d 100644 (file)
@@ -183,6 +183,9 @@ static int resp_get_length(netdissect_options *, const u_char *, int, const u_ch
  * TEST_RET_LEN
  * If ret_len is < 0, jump to the trunc tag which returns (-1)
  * and 'bubbles up' to printing tstr. Otherwise, return ret_len.
+ *
+ * Note that using this macro with a semicolon at the end emits a warning from
+ * Sun C about an unreachable statement (the semicolon is the statement).
  */
 #define TEST_RET_LEN(rl) \
     if (rl < 0) { goto trunc; } else { return rl; }
@@ -260,7 +263,7 @@ resp_parse(netdissect_options *ndo, const u_char *bp, int length)
      * including invalid packet errors; that's what we want, as
      * we have to give up on further parsing in that case.
      */
-    TEST_RET_LEN(ret_len);
+    TEST_RET_LEN(ret_len) // without a semicolon
 
 trunc:
     return (-1);
@@ -310,7 +313,7 @@ resp_print_string_error_integer(netdissect_options *ndo, const u_char *bp, int l
     RESP_PRINT_SEGMENT(ndo, bp, len);
     ret_len = 1 /*<opcode>*/ + len /*<string>*/ + 2 /*<CRLF>*/;
 
-    TEST_RET_LEN(ret_len);
+    TEST_RET_LEN(ret_len) // without a semicolon
 
 trunc:
     return (-1);
index c2f86ff48bb4fff277b16ffc4f51a1192cf8dff7..6110e2a01f2f1ce885cb23b83c0f1610b0a7b1bf 100644 (file)
@@ -165,7 +165,6 @@ rt6_print(netdissect_options *ndo, const u_char *bp, const u_char *bp2 _U_)
                /*(*/
                ND_PRINT(") ");
                return((GET_U_1(dp0->ip6r0_len) + 1) << 3);
-               break;
        case IPV6_RTHDR_TYPE_4:
                srh = (const struct ip6_srh *)dp;
                last_entry = GET_U_1(srh->srh_last_ent);
@@ -195,7 +194,6 @@ rt6_print(netdissect_options *ndo, const u_char *bp, const u_char *bp2 _U_)
                /*(*/
                ND_PRINT(") ");
                return((GET_U_1(srh->srh_len) + 1) << 3);
-               break;
        default:
                ND_PRINT(" (unknown type)");
                goto invalid;
index e512e324d6a056a11853ba362d6e25b3faa3a5b4..e366ae4b66898d5c5b56f0417536ac64b6003600 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -891,7 +891,6 @@ smb_fdata(netdissect_options *ndo,
             */
            fmt++;
            return(buf);
-           break;
 
        case '[':
            /*
index 2defca332913ce34dc1e03bc4d675554cb0e144e..80fd23d74f99cc7677ffb80d9ff981498ca5d44d 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1740,7 +1740,7 @@ main(int argc, char **argv)
                case 'h':
                        print_usage(stdout);
                        exit_tcpdump(S_SUCCESS);
-                       break;
+                       /* NOTREACHED */
 
                case 'H':
                        ++ndo->ndo_Hflag;
@@ -1988,7 +1988,7 @@ main(int argc, char **argv)
                case OPTION_VERSION:
                        print_version(stdout);
                        exit_tcpdump(S_SUCCESS);
-                       break;
+                       /* NOTREACHED */
 
 #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
                case OPTION_TSTAMP_PRECISION:
@@ -2068,7 +2068,7 @@ main(int argc, char **argv)
 
        default: /* Not supported */
                error("only -t, -tt, -ttt, -tttt and -ttttt are supported");
-               break;
+               /* NOTREACHED */
        }
 
        if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL))