Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit41c912c

Browse files
committed
Clean up warnings from -Wimplicit-fallthrough.
Recent gcc can warn about switch-case fall throughs that are notexplicitly labeled as intentional. This seems like a good thing,so clean up the warnings exposed thereby by labeling all suchcases with comments that gcc will recognize.In files that already had one or more suitable comments, I generallymatched the existing style of those. Otherwise I went with/* FALLTHROUGH */, which is one of the spellings approved at themore-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 includeadditional text in the same comment, so some existing commentscontaining versions of this aren't good enough.)Testing with gcc 8.0.1 (Fedora 28's current version), I found thatI also had to put explicit "break"s after elog(ERROR) or ereport(ERROR);apparently, for this purpose gcc doesn't recognize that those don'treturn. That seems like possibly a gcc bug, but it's fine becausein most places we did that anyway; so this amounts to a visit from thestyle police.Discussion:https://postgr.es/m/15083.1525207729@sss.pgh.pa.us
1 parent1667148 commit41c912c

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
caseBTGreaterEqualStrategyNumber:
8989
caseBTGreaterStrategyNumber:
9090
*ptr_partialmatch= true;
91+
/* FALLTHROUGH */
9192
caseBTEqualStrategyNumber:
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
caseLH_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
caseLH_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
case9:
468468
c+= ((uint32)k[8] <<24);
469-
/* the lowest byte of c is reserved for the length */
470469
/* fall through */
471470
case8:
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
case9:
507507
c+= ((uint32)k[8] <<8);
508-
/* the lowest byte of c is reserved for the length */
509508
/* fall through */
510509
case8:
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
#ifdefWORDS_BIGENDIAN
561-
switch (len)/* all the case statements fall through */
561+
switch (len)
562562
{
563563
case11:
564564
c+= ((uint32)k[10] <<8);
565+
/* fall through */
565566
case10:
566567
c+= ((uint32)k[9] <<16);
568+
/* fall through */
567569
case9:
568570
c+= ((uint32)k[8] <<24);
569-
/*the lowest byte of c is reserved for the length */
571+
/*fall through */
570572
case8:
573+
/* the lowest byte of c is reserved for the length */
571574
b+=k[7];
575+
/* fall through */
572576
case7:
573577
b+= ((uint32)k[6] <<8);
578+
/* fall through */
574579
case6:
575580
b+= ((uint32)k[5] <<16);
581+
/* fall through */
576582
case5:
577583
b+= ((uint32)k[4] <<24);
584+
/* fall through */
578585
case4:
579586
a+=k[3];
587+
/* fall through */
580588
case3:
581589
a+= ((uint32)k[2] <<8);
590+
/* fall through */
582591
case2:
583592
a+= ((uint32)k[1] <<16);
593+
/* fall through */
584594
case1:
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
case11:
592602
c+= ((uint32)k[10] <<24);
603+
/* fall through */
593604
case10:
594605
c+= ((uint32)k[9] <<16);
606+
/* fall through */
595607
case9:
596608
c+= ((uint32)k[8] <<8);
597-
/*the lowest byte of c is reserved for the length */
609+
/*fall through */
598610
case8:
611+
/* the lowest byte of c is reserved for the length */
599612
b+= ((uint32)k[7] <<24);
613+
/* fall through */
600614
case7:
601615
b+= ((uint32)k[6] <<16);
616+
/* fall through */
602617
case6:
603618
b+= ((uint32)k[5] <<8);
619+
/* fall through */
604620
case5:
605621
b+=k[4];
622+
/* fall through */
606623
case4:
607624
a+= ((uint32)k[3] <<24);
625+
/* fall through */
608626
case3:
609627
a+= ((uint32)k[2] <<16);
628+
/* fall through */
610629
case2:
611630
a+= ((uint32)k[1] <<8);
631+
/* fall through */
612632
case1:
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
case9:
688708
c+= ((uint32)k[8] <<24);
689-
/* the lowest byte of c is reserved for the length */
690709
/* fall through */
691710
case8:
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
case9:
727747
c+= ((uint32)k[8] <<8);
728-
/* the lowest byte of c is reserved for the length */
729748
/* fall through */
730749
case8:
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
#ifdefWORDS_BIGENDIAN
781-
switch (len)/* all the case statements fall through */
801+
switch (len)
782802
{
783803
case11:
784804
c+= ((uint32)k[10] <<8);
805+
/* fall through */
785806
case10:
786807
c+= ((uint32)k[9] <<16);
808+
/* fall through */
787809
case9:
788810
c+= ((uint32)k[8] <<24);
789-
/*the lowest byte of c is reserved for the length */
811+
/*fall through */
790812
case8:
813+
/* the lowest byte of c is reserved for the length */
791814
b+=k[7];
815+
/* fall through */
792816
case7:
793817
b+= ((uint32)k[6] <<8);
818+
/* fall through */
794819
case6:
795820
b+= ((uint32)k[5] <<16);
821+
/* fall through */
796822
case5:
797823
b+= ((uint32)k[4] <<24);
824+
/* fall through */
798825
case4:
799826
a+=k[3];
827+
/* fall through */
800828
case3:
801829
a+= ((uint32)k[2] <<8);
830+
/* fall through */
802831
case2:
803832
a+= ((uint32)k[1] <<16);
833+
/* fall through */
804834
case1:
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
case11:
812842
c+= ((uint32)k[10] <<24);
843+
/* fall through */
813844
case10:
814845
c+= ((uint32)k[9] <<16);
846+
/* fall through */
815847
case9:
816848
c+= ((uint32)k[8] <<8);
817-
/*the lowest byte of c is reserved for the length */
849+
/*fall through */
818850
case8:
851+
/* the lowest byte of c is reserved for the length */
819852
b+= ((uint32)k[7] <<24);
853+
/* fall through */
820854
case7:
821855
b+= ((uint32)k[6] <<16);
856+
/* fall through */
822857
case6:
823858
b+= ((uint32)k[5] <<8);
859+
/* fall through */
824860
case5:
825861
b+=k[4];
862+
/* fall through */
826863
case4:
827864
a+= ((uint32)k[3] <<24);
865+
/* fall through */
828866
case3:
829867
a+= ((uint32)k[2] <<16);
868+
/* fall through */
830869
case2:
831870
a+= ((uint32)k[1] <<8);
871+
/* fall through */
832872
case1:
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
caseOBJECT_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
caseT_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
caseT_SeqScan:
14841485
caseT_ValuesScan:
14851486
caseT_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
caseHeapTupleInvisible:
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
caseHeapTupleInvisible:
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
gotoretry;
203203
caseHeapTupleInvisible:
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
gotoretry;
366367
caseHeapTupleInvisible:
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
caseHeapTupleInvisible:
258258
elog(ERROR,"attempted to lock invisible tuple");
259+
break;
259260

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

‎src/backend/executor/nodeModifyTable.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
13901390

13911391
/* This shouldn't happen */
13921392
elog(ERROR,"attempted to lock invisible tuple");
1393+
break;
13931394

13941395
caseHeapTupleSelfUpdated:
13951396

@@ -1399,6 +1400,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
13991400
* seen this row to conflict with.
14001401
*/
14011402
elog(ERROR,"unexpected self-updated tuple");
1403+
break;
14021404

14031405
caseHeapTupleUpdated:
14041406
if (IsolationUsesXactSnapshot())

‎src/backend/parser/gram.y

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14855,18 +14855,21 @@ RoleId:RoleSpec
1485514855
errmsg("role name\"%s\" is reserved",
1485614856
"public"),
1485714857
parser_errposition(@1)));
14858+
break;
1485814859
case ROLESPEC_SESSION_USER:
1485914860
ereport(ERROR,
1486014861
(errcode(ERRCODE_RESERVED_NAME),
1486114862
errmsg("%s cannot be used as a role name here",
1486214863
"SESSION_USER"),
1486314864
parser_errposition(@1)));
14865+
break;
1486414866
case ROLESPEC_CURRENT_USER:
1486514867
ereport(ERROR,
1486614868
(errcode(ERRCODE_RESERVED_NAME),
1486714869
errmsg("%s cannot be used as a role name here",
1486814870
"CURRENT_USER"),
1486914871
parser_errposition(@1)));
14872+
break;
1487014873
}
1487114874
}
1487214875
;

‎src/backend/parser/parse_utilcmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,12 +3829,14 @@ validateInfiniteBounds(ParseState *pstate, List *blist)
38293829
(errcode(ERRCODE_DATATYPE_MISMATCH),
38303830
errmsg("every bound following MAXVALUE must also be MAXVALUE"),
38313831
parser_errposition(pstate,exprLocation((Node*)prd))));
3832+
break;
38323833

38333834
casePARTITION_RANGE_DATUM_MINVALUE:
38343835
ereport(ERROR,
38353836
(errcode(ERRCODE_DATATYPE_MISMATCH),
38363837
errmsg("every bound following MINVALUE must also be MINVALUE"),
38373838
parser_errposition(pstate,exprLocation((Node*)prd))));
3839+
break;
38383840
}
38393841
}
38403842
}

‎src/backend/regex/regc_lex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ lexescape(struct vars *v)
875875
/* oops, doesn't look like it's a backref after all... */
876876
v->now=save;
877877
/* and fall through into octal number */
878+
/* FALLTHROUGH */
878879
caseCHR('0'):
879880
NOTE(REG_UUNPORT);
880881
v->now--;/* put first digit back */

‎src/backend/regex/regcomp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,8 @@ parseqatom(struct vars *v,
909909
}
910910
/* legal in EREs due to specification botch */
911911
NOTE(REG_UPBOTCH);
912-
/* fallthrough into case PLAIN */
912+
/* fall through into case PLAIN */
913+
/* FALLTHROUGH */
913914
casePLAIN:
914915
onechr(v,v->nextvalue,lp,rp);
915916
okcolors(v->nfa,v->cm);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp