Skip to content

Commit 41c912c

Browse files
committed
Clean up warnings from -Wimplicit-fallthrough.
Recent gcc can warn about switch-case fall throughs that are not explicitly labeled as intentional. This seems like a good thing, so clean up the warnings exposed thereby by labeling all such cases with comments that gcc will recognize. In files that already had one or more suitable comments, I generally matched the existing style of those. Otherwise I went with /* FALLTHROUGH */, which is one of the spellings approved at the more-restrictive-than-default level -Wimplicit-fallthrough=4. (At the default level you can also spell it /* FALL ?THRU */, and it's not picky about case. What you can't do is include additional text in the same comment, so some existing comments containing versions of this aren't good enough.) Testing with gcc 8.0.1 (Fedora 28's current version), I found that I also had to put explicit "break"s after elog(ERROR) or ereport(ERROR); apparently, for this purpose gcc doesn't recognize that those don't return. That seems like possibly a gcc bug, but it's fine because in most places we did that anyway; so this amounts to a visit from the style police. Discussion: https://postgr.es/m/15083.1525207729@sss.pgh.pa.us
1 parent 1667148 commit 41c912c

File tree

28 files changed

+128
-25
lines changed

28 files changed

+128
-25
lines changed

contrib/btree_gin/btree_gin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
8888
case BTGreaterEqualStrategyNumber:
8989
case BTGreaterStrategyNumber:
9090
*ptr_partialmatch = true;
91+
/* FALLTHROUGH */
9192
case BTEqualStrategyNumber:
9293
entries[0] = datum;
9394
break;

contrib/pageinspect/hashfuncs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,22 @@ verify_hash_page(bytea *raw_page, int flags)
9797
ereport(ERROR,
9898
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
9999
errmsg("page is not a hash meta page")));
100+
break;
100101
case LH_BUCKET_PAGE | LH_OVERFLOW_PAGE:
101102
ereport(ERROR,
102103
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
103104
errmsg("page is not a hash bucket or overflow page")));
105+
break;
104106
case LH_OVERFLOW_PAGE:
105107
ereport(ERROR,
106108
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
107109
errmsg("page is not a hash overflow page")));
110+
break;
108111
default:
109112
elog(ERROR,
110113
"hash page of type %08x not in mask %08x",
111114
pagetype, flags);
115+
break;
112116
}
113117
}
114118

src/backend/access/hash/hashfunc.c

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,9 @@ hash_any(register const unsigned char *k, register int keylen)
466466
/* fall through */
467467
case 9:
468468
c += ((uint32) k[8] << 24);
469-
/* the lowest byte of c is reserved for the length */
470469
/* fall through */
471470
case 8:
471+
/* the lowest byte of c is reserved for the length */
472472
b += ka[1];
473473
a += ka[0];
474474
break;
@@ -505,9 +505,9 @@ hash_any(register const unsigned char *k, register int keylen)
505505
/* fall through */
506506
case 9:
507507
c += ((uint32) k[8] << 8);
508-
/* the lowest byte of c is reserved for the length */
509508
/* fall through */
510509
case 8:
510+
/* the lowest byte of c is reserved for the length */
511511
b += ka[1];
512512
a += ka[0];
513513
break;
@@ -558,57 +558,77 @@ hash_any(register const unsigned char *k, register int keylen)
558558

559559
/* handle the last 11 bytes */
560560
#ifdef WORDS_BIGENDIAN
561-
switch (len) /* all the case statements fall through */
561+
switch (len)
562562
{
563563
case 11:
564564
c += ((uint32) k[10] << 8);
565+
/* fall through */
565566
case 10:
566567
c += ((uint32) k[9] << 16);
568+
/* fall through */
567569
case 9:
568570
c += ((uint32) k[8] << 24);
569-
/* the lowest byte of c is reserved for the length */
571+
/* fall through */
570572
case 8:
573+
/* the lowest byte of c is reserved for the length */
571574
b += k[7];
575+
/* fall through */
572576
case 7:
573577
b += ((uint32) k[6] << 8);
578+
/* fall through */
574579
case 6:
575580
b += ((uint32) k[5] << 16);
581+
/* fall through */
576582
case 5:
577583
b += ((uint32) k[4] << 24);
584+
/* fall through */
578585
case 4:
579586
a += k[3];
587+
/* fall through */
580588
case 3:
581589
a += ((uint32) k[2] << 8);
590+
/* fall through */
582591
case 2:
583592
a += ((uint32) k[1] << 16);
593+
/* fall through */
584594
case 1:
585595
a += ((uint32) k[0] << 24);
586596
/* case 0: nothing left to add */
587597
}
588598
#else /* !WORDS_BIGENDIAN */
589-
switch (len) /* all the case statements fall through */
599+
switch (len)
590600
{
591601
case 11:
592602
c += ((uint32) k[10] << 24);
603+
/* fall through */
593604
case 10:
594605
c += ((uint32) k[9] << 16);
606+
/* fall through */
595607
case 9:
596608
c += ((uint32) k[8] << 8);
597-
/* the lowest byte of c is reserved for the length */
609+
/* fall through */
598610
case 8:
611+
/* the lowest byte of c is reserved for the length */
599612
b += ((uint32) k[7] << 24);
613+
/* fall through */
600614
case 7:
601615
b += ((uint32) k[6] << 16);
616+
/* fall through */
602617
case 6:
603618
b += ((uint32) k[5] << 8);
619+
/* fall through */
604620
case 5:
605621
b += k[4];
622+
/* fall through */
606623
case 4:
607624
a += ((uint32) k[3] << 24);
625+
/* fall through */
608626
case 3:
609627
a += ((uint32) k[2] << 16);
628+
/* fall through */
610629
case 2:
611630
a += ((uint32) k[1] << 8);
631+
/* fall through */
612632
case 1:
613633
a += k[0];
614634
/* case 0: nothing left to add */
@@ -686,9 +706,9 @@ hash_any_extended(register const unsigned char *k, register int keylen,
686706
/* fall through */
687707
case 9:
688708
c += ((uint32) k[8] << 24);
689-
/* the lowest byte of c is reserved for the length */
690709
/* fall through */
691710
case 8:
711+
/* the lowest byte of c is reserved for the length */
692712
b += ka[1];
693713
a += ka[0];
694714
break;
@@ -725,9 +745,9 @@ hash_any_extended(register const unsigned char *k, register int keylen,
725745
/* fall through */
726746
case 9:
727747
c += ((uint32) k[8] << 8);
728-
/* the lowest byte of c is reserved for the length */
729748
/* fall through */
730749
case 8:
750+
/* the lowest byte of c is reserved for the length */
731751
b += ka[1];
732752
a += ka[0];
733753
break;
@@ -778,57 +798,77 @@ hash_any_extended(register const unsigned char *k, register int keylen,
778798

779799
/* handle the last 11 bytes */
780800
#ifdef WORDS_BIGENDIAN
781-
switch (len) /* all the case statements fall through */
801+
switch (len)
782802
{
783803
case 11:
784804
c += ((uint32) k[10] << 8);
805+
/* fall through */
785806
case 10:
786807
c += ((uint32) k[9] << 16);
808+
/* fall through */
787809
case 9:
788810
c += ((uint32) k[8] << 24);
789-
/* the lowest byte of c is reserved for the length */
811+
/* fall through */
790812
case 8:
813+
/* the lowest byte of c is reserved for the length */
791814
b += k[7];
815+
/* fall through */
792816
case 7:
793817
b += ((uint32) k[6] << 8);
818+
/* fall through */
794819
case 6:
795820
b += ((uint32) k[5] << 16);
821+
/* fall through */
796822
case 5:
797823
b += ((uint32) k[4] << 24);
824+
/* fall through */
798825
case 4:
799826
a += k[3];
827+
/* fall through */
800828
case 3:
801829
a += ((uint32) k[2] << 8);
830+
/* fall through */
802831
case 2:
803832
a += ((uint32) k[1] << 16);
833+
/* fall through */
804834
case 1:
805835
a += ((uint32) k[0] << 24);
806836
/* case 0: nothing left to add */
807837
}
808838
#else /* !WORDS_BIGENDIAN */
809-
switch (len) /* all the case statements fall through */
839+
switch (len)
810840
{
811841
case 11:
812842
c += ((uint32) k[10] << 24);
843+
/* fall through */
813844
case 10:
814845
c += ((uint32) k[9] << 16);
846+
/* fall through */
815847
case 9:
816848
c += ((uint32) k[8] << 8);
817-
/* the lowest byte of c is reserved for the length */
849+
/* fall through */
818850
case 8:
851+
/* the lowest byte of c is reserved for the length */
819852
b += ((uint32) k[7] << 24);
853+
/* fall through */
820854
case 7:
821855
b += ((uint32) k[6] << 16);
856+
/* fall through */
822857
case 6:
823858
b += ((uint32) k[5] << 8);
859+
/* fall through */
824860
case 5:
825861
b += k[4];
862+
/* fall through */
826863
case 4:
827864
a += ((uint32) k[3] << 24);
865+
/* fall through */
828866
case 3:
829867
a += ((uint32) k[2] << 16);
868+
/* fall through */
830869
case 2:
831870
a += ((uint32) k[1] << 8);
871+
/* fall through */
832872
case 1:
833873
a += k[0];
834874
/* case 0: nothing left to add */

src/backend/catalog/objectaddress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
20922092
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
20932093
errmsg("name list length must be at least %d", 3)));
20942094
/* fall through to check args length */
2095+
/* FALLTHROUGH */
20952096
case OBJECT_OPERATOR:
20962097
if (list_length(args) != 2)
20972098
ereport(ERROR,

src/backend/commands/explain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
14791479
case T_SampleScan:
14801480
show_tablesample(((SampleScan *) plan)->tablesample,
14811481
planstate, ancestors, es);
1482-
/* FALL THRU to print additional fields the same as SeqScan */
1482+
/* fall through to print additional fields the same as SeqScan */
1483+
/* FALLTHROUGH */
14831484
case T_SeqScan:
14841485
case T_ValuesScan:
14851486
case T_CteScan:

src/backend/commands/indexcmds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ DefineIndex(Oid relationId,
440440
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
441441
errmsg("cannot create index on foreign table \"%s\"",
442442
RelationGetRelationName(rel))));
443+
break;
443444
default:
444445
ereport(ERROR,
445446
(errcode(ERRCODE_WRONG_OBJECT_TYPE),

src/backend/commands/trigger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,6 +3338,7 @@ ltrmark:;
33383338

33393339
case HeapTupleInvisible:
33403340
elog(ERROR, "attempted to lock invisible tuple");
3341+
break;
33413342

33423343
default:
33433344
ReleaseBuffer(buffer);

src/backend/executor/execMain.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,6 +2741,7 @@ EvalPlanQualFetch(EState *estate, Relation relation, int lockmode,
27412741

27422742
case HeapTupleInvisible:
27432743
elog(ERROR, "attempted to lock invisible tuple");
2744+
break;
27442745

27452746
default:
27462747
ReleaseBuffer(buffer);

src/backend/executor/execReplication.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
202202
goto retry;
203203
case HeapTupleInvisible:
204204
elog(ERROR, "attempted to lock invisible tuple");
205+
break;
205206
default:
206207
elog(ERROR, "unexpected heap_lock_tuple status: %u", res);
207208
break;
@@ -365,6 +366,7 @@ RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
365366
goto retry;
366367
case HeapTupleInvisible:
367368
elog(ERROR, "attempted to lock invisible tuple");
369+
break;
368370
default:
369371
elog(ERROR, "unexpected heap_lock_tuple status: %u", res);
370372
break;

src/backend/executor/nodeLockRows.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ ExecLockRows(PlanState *pstate)
256256

257257
case HeapTupleInvisible:
258258
elog(ERROR, "attempted to lock invisible tuple");
259+
break;
259260

260261
default:
261262
elog(ERROR, "unrecognized heap_lock_tuple status: %u",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy