Skip to content

Commit 7d6a285

Browse files
infrastationguyharris
authored andcommitted
Address various E_STATEMENT_NOT_REACHED from Sun C.
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
1 parent 476dc88 commit 7d6a285

12 files changed

+12
-40
lines changed

print-802_15_4.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -513,20 +513,16 @@ ieee802_15_4_addr_len(uint16_t addr_type)
513513
switch (addr_type) {
514514
case FC_ADDRESSING_MODE_NONE: /* None. */
515515
return 0;
516-
break;
517516
case FC_ADDRESSING_MODE_RESERVED: /* Reserved, there used to be 8-bit
518517
* address type in one amendment, but
519518
* that and the feature using it was
520519
* removed during 802.15.4-2015
521520
* maintenance process. */
522521
return -1;
523-
break;
524522
case FC_ADDRESSING_MODE_SHORT: /* Short. */
525523
return 2;
526-
break;
527524
case FC_ADDRESSING_MODE_LONG: /* Extended. */
528525
return 8;
529-
break;
530526
}
531527
return 0;
532528
}
@@ -1388,8 +1384,6 @@ ieee802_15_4_print_mpx_ie(netdissect_options *ndo,
13881384
}
13891385
}
13901386
return;
1391-
/* NOTREACHED */
1392-
break;
13931387
case 0x03: /* Reserved */
13941388
case 0x05: /* Reserved */
13951389
case 0x07: /* Reserved */
@@ -1554,7 +1548,6 @@ ieee802_15_4_print_aux_sec_header(netdissect_options *ndo,
15541548
ND_PRINT("Implicit");
15551549
}
15561550
return len;
1557-
break;
15581551
case 0x01: /* Key Index, nothing to print here. */
15591552
break;
15601553
case 0x02: /* PAN and Short address Key Source, and Key Index. */
@@ -1632,7 +1625,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
16321625
"Allocate address, " : ""));
16331626
return caplen;
16341627
}
1635-
break;
1628+
/* NOTREACHED */
16361629
case 0x02: /* Association Response */
16371630
if (caplen != 3) {
16381631
ND_PRINT("Invalid Association response command length");
@@ -1663,7 +1656,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
16631656
}
16641657
return caplen;
16651658
}
1666-
break;
1659+
/* NOTREACHED */
16671660
case 0x03: /* Disassociation Notification command */
16681661
if (caplen != 1) {
16691662
ND_PRINT("Invalid Disassociation Notification command length");
@@ -1723,7 +1716,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
17231716
ieee802_15_4_print_addr(ndo, p + 5, 2);
17241717
return caplen;
17251718
}
1726-
break;
1719+
/* NOTREACHED */
17271720
case 0x09: /* GTS Request command */
17281721
if (caplen != 1) {
17291722
ND_PRINT("Invalid GTS Request command length");
@@ -1740,7 +1733,7 @@ ieee802_15_4_print_command_data(netdissect_options *ndo,
17401733
"GTS allocation" : "GTS deallocations"));
17411734
return caplen;
17421735
}
1743-
break;
1736+
/* NOTREACHED */
17441737
case 0x13: /* DSME Association Request command */
17451738
/* XXX Not implemented */
17461739
case 0x14: /* DSME Association Response command */
@@ -2493,19 +2486,14 @@ ieee802_15_4_print(netdissect_options *ndo,
24932486
case 0x02: /* Acknowledgement */
24942487
case 0x03: /* MAC Command */
24952488
return ieee802_15_4_std_frames(ndo, p, caplen, fc);
2496-
break;
24972489
case 0x04: /* Reserved */
24982490
return 0;
2499-
break;
25002491
case 0x05: /* Multipurpose */
25012492
return ieee802_15_4_mp_frame(ndo, p, caplen, fc);
2502-
break;
25032493
case 0x06: /* Fragment or Frak */
25042494
return ieee802_15_4_frag_frame(ndo, p, caplen, fc);
2505-
break;
25062495
case 0x07: /* Extended */
25072496
return 0;
2508-
break;
25092497
}
25102498
return 0;
25112499
}

print-bgp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,6 @@ bgp_attr_print(netdissect_options *ndo,
22502250
tlen -= tnhlen;
22512251
tnhlen = 0;
22522252
goto done;
2253-
break;
22542253
}
22552254
}
22562255
}

print-dccp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
392392
break;
393393
default:
394394
goto invalid;
395-
break;
396395
}
397396

398397
if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
@@ -596,7 +595,6 @@ dccp_print_option(netdissect_options *ndo, const u_char *bp, u_int hlen)
596595
default:
597596
ND_PRINT(" [optlen != 6 or 8 or 10]");
598597
goto invalid;
599-
break;
600598
}
601599
break;
602600
case DCCP_OPTION_ELAPSED_TIME:

print-juniper.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,6 @@ juniper_ppp_heuristic_guess(netdissect_options *ndo,
11661166

11671167
default:
11681168
return 0; /* did not find a ppp header */
1169-
break;
11701169
}
11711170
return 1; /* we printed a ppp packet */
11721171
}
@@ -1210,7 +1209,6 @@ ip_heuristic_guess(netdissect_options *ndo,
12101209
break;
12111210
default:
12121211
return 0; /* did not find a ip header */
1213-
break;
12141212
}
12151213
return 1; /* we printed an v4/v6 packet */
12161214
}

print-lisp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
320320
* No support for LCAF right now.
321321
*/
322322
return;
323-
break;
324323
}
325324

326325
ND_PRINT(" %u locator(s)", loc_count);

print-mobility.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ mobility_print(netdissect_options *ndo,
319319
default:
320320
ND_PRINT(" len=%u", GET_U_1(mh->ip6m_len));
321321
return(mhlen);
322-
break;
323322
}
324323
if (ndo->ndo_vflag)
325324
if (mobility_opt_print(ndo, bp + hlen, mhlen - hlen))

print-pgm.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ pgm_print(netdissect_options *ndo,
274274
break;
275275
default:
276276
goto invalid;
277-
break;
278277
}
279278

280279
ND_PRINT("SPM seq %u trail %u lead %u nla %s",
@@ -306,7 +305,6 @@ pgm_print(netdissect_options *ndo,
306305
break;
307306
default:
308307
goto invalid;
309-
break;
310308
}
311309

312310
ivl = GET_BE_U_4(bp);
@@ -384,7 +382,6 @@ pgm_print(netdissect_options *ndo,
384382
break;
385383
default:
386384
goto invalid;
387-
break;
388385
}
389386

390387
/*
@@ -405,7 +402,6 @@ pgm_print(netdissect_options *ndo,
405402
break;
406403
default:
407404
goto invalid;
408-
break;
409405
}
410406

411407
/*
@@ -630,7 +626,6 @@ pgm_print(netdissect_options *ndo,
630626
break;
631627
default:
632628
goto invalid;
633-
break;
634629
}
635630

636631
ND_PRINT(" REDIRECT %s", nla_buf);
@@ -787,7 +782,6 @@ pgm_print(netdissect_options *ndo,
787782
break;
788783
default:
789784
goto invalid;
790-
break;
791785
}
792786

793787
ND_PRINT(" PGMCC DATA %u %s", offset, nla_buf);
@@ -830,7 +824,6 @@ pgm_print(netdissect_options *ndo,
830824
break;
831825
default:
832826
goto invalid;
833-
break;
834827
}
835828

836829
ND_PRINT(" PGMCC FEEDBACK %u %s", offset, nla_buf);

print-pim.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ pimv2_addr_print(netdissect_options *ndo,
584584
break;
585585
default:
586586
return -1;
587-
break;
588587
}
589588
hdrlen = 0;
590589
}
@@ -813,7 +812,6 @@ pimv2_print(netdissect_options *ndo,
813812
ND_PRINT("[option length %u != 4]", olen);
814813
nd_print_invalid(ndo);
815814
return;
816-
break;
817815
}
818816
break;
819817

print-resp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ static int resp_get_length(netdissect_options *, const u_char *, int, const u_ch
183183
* TEST_RET_LEN
184184
* If ret_len is < 0, jump to the trunc tag which returns (-1)
185185
* and 'bubbles up' to printing tstr. Otherwise, return ret_len.
186+
*
187+
* Note that using this macro with a semicolon at the end emits a warning from
188+
* Sun C about an unreachable statement (the semicolon is the statement).
186189
*/
187190
#define TEST_RET_LEN(rl) \
188191
if (rl < 0) { goto trunc; } else { return rl; }
@@ -260,7 +263,7 @@ resp_parse(netdissect_options *ndo, const u_char *bp, int length)
260263
* including invalid packet errors; that's what we want, as
261264
* we have to give up on further parsing in that case.
262265
*/
263-
TEST_RET_LEN(ret_len);
266+
TEST_RET_LEN(ret_len) // without a semicolon
264267

265268
trunc:
266269
return (-1);
@@ -310,7 +313,7 @@ resp_print_string_error_integer(netdissect_options *ndo, const u_char *bp, int l
310313
RESP_PRINT_SEGMENT(ndo, bp, len);
311314
ret_len = 1 /*<opcode>*/ + len /*<string>*/ + 2 /*<CRLF>*/;
312315

313-
TEST_RET_LEN(ret_len);
316+
TEST_RET_LEN(ret_len) // without a semicolon
314317

315318
trunc:
316319
return (-1);

print-rt6.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ rt6_print(netdissect_options *ndo, const u_char *bp, const u_char *bp2 _U_)
165165
/*(*/
166166
ND_PRINT(") ");
167167
return((GET_U_1(dp0->ip6r0_len) + 1) << 3);
168-
break;
169168
case IPV6_RTHDR_TYPE_4:
170169
srh = (const struct ip6_srh *)dp;
171170
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_)
195194
/*(*/
196195
ND_PRINT(") ");
197196
return((GET_U_1(srh->srh_len) + 1) << 3);
198-
break;
199197
default:
200198
ND_PRINT(" (unknown type)");
201199
goto invalid;

0 commit comments

Comments
 (0)