Skip to content

Commit 88c5083

Browse files
committed
Merge tag 'Wimplicit-fallthrough-5.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux
Pull Wimplicit-fallthrough enablement from Gustavo A. R. Silva: "This marks switch cases where we are expecting to fall through, and globally enables the -Wimplicit-fallthrough option in the main Makefile. Finally, some missing-break fixes that have been tagged for -stable: - drm/amdkfd: Fix missing break in switch statement - drm/amdgpu/gfx10: Fix missing break in switch statement With these changes, we completely get rid of all the fall-through warnings in the kernel" * tag 'Wimplicit-fallthrough-5.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux: Makefile: Globally enable fall-through warning drm/i915: Mark expected switch fall-throughs drm/amd/display: Mark expected switch fall-throughs drm/amdkfd/kfd_mqd_manager_v10: Avoid fall-through warning drm/amdgpu/gfx10: Fix missing break in switch statement drm/amdkfd: Fix missing break in switch statement perf/x86/intel: Mark expected switch fall-throughs mtd: onenand_base: Mark expected switch fall-through afs: fsclient: Mark expected switch fall-throughs afs: yfsclient: Mark expected switch fall-throughs can: mark expected switch fall-throughs firewire: mark expected switch fall-throughs
2 parents 43e317c + a035d55 commit 88c5083

File tree

23 files changed

+111
-49
lines changed

23 files changed

+111
-49
lines changed

Documentation/process/deprecated.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
119119
lead to a crash, possible overwriting sensitive contents at the end of the
120120
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
121121
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
122+
123+
Implicit switch case fall-through
124+
---------------------------------
125+
The C language allows switch cases to "fall through" when
126+
a "break" statement is missing at the end of a case. This,
127+
however, introduces ambiguity in the code, as it's not always
128+
clear if the missing break is intentional or a bug. As there
129+
have been a long list of flaws `due to missing "break" statements
130+
<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
131+
"implicit fall-through". In order to identify an intentional fall-through
132+
case, we have adopted the marking used by static analyzers: a comment
133+
saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
134+
is more widely handled by C compilers, static analyzers, and IDEs, we can
135+
switch to using that instead.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
843843
# warn about C99 declaration after statement
844844
KBUILD_CFLAGS += -Wdeclaration-after-statement
845845

846+
# Warn about unmarked fall-throughs in switch statement.
847+
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
848+
846849
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
847850
KBUILD_CFLAGS += -Wvla
848851

arch/x86/events/intel/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4955,6 +4955,7 @@ __init int intel_pmu_init(void)
49554955

49564956
case INTEL_FAM6_SKYLAKE_X:
49574957
pmem = true;
4958+
/* fall through */
49584959
case INTEL_FAM6_SKYLAKE_MOBILE:
49594960
case INTEL_FAM6_SKYLAKE_DESKTOP:
49604961
case INTEL_FAM6_KABYLAKE_MOBILE:
@@ -5004,6 +5005,7 @@ __init int intel_pmu_init(void)
50045005
case INTEL_FAM6_ICELAKE_X:
50055006
case INTEL_FAM6_ICELAKE_XEON_D:
50065007
pmem = true;
5008+
/* fall through */
50075009
case INTEL_FAM6_ICELAKE_MOBILE:
50085010
case INTEL_FAM6_ICELAKE_DESKTOP:
50095011
x86_pmu.late_ack = true;

drivers/firewire/core-device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ static void set_broadcast_channel(struct fw_device *device, int generation)
957957
device->bc_implemented = BC_IMPLEMENTED;
958958
break;
959959
}
960-
/* else fall through to case address error */
960+
/* else, fall through - to case address error */
961961
case RCODE_ADDRESS_ERROR:
962962
device->bc_implemented = BC_UNIMPLEMENTED;
963963
}

drivers/firewire/core-iso.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
284284
if ((data[0] & bit) == (data[1] & bit))
285285
continue;
286286

287-
/* 1394-1995 IRM, fall through to retry. */
287+
/* fall through - It's a 1394-1995 IRM, retry. */
288288
default:
289289
if (retry) {
290290
retry--;

drivers/firewire/core-topology.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count)
5454
switch (port_type) {
5555
case SELFID_PORT_CHILD:
5656
(*child_port_count)++;
57+
/* fall through */
5758
case SELFID_PORT_PARENT:
5859
case SELFID_PORT_NCONN:
5960
(*total_port_count)++;

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4620,6 +4620,7 @@ gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
46204620
cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
46214621
TIME_STAMP_INT_ENABLE, 0);
46224622
WREG32(cp_int_cntl_reg, cp_int_cntl);
4623+
break;
46234624
case AMDGPU_IRQ_STATE_ENABLE:
46244625
cp_int_cntl = RREG32(cp_int_cntl_reg);
46254626
cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,

drivers/gpu/drm/amd/amdkfd/kfd_crat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev,
668668
case CHIP_RAVEN:
669669
pcache_info = raven_cache_info;
670670
num_of_cache_types = ARRAY_SIZE(raven_cache_info);
671+
break;
671672
case CHIP_NAVI10:
672673
pcache_info = navi10_cache_info;
673674
num_of_cache_types = ARRAY_SIZE(navi10_cache_info);

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ struct mqd_manager *mqd_manager_init_v10(enum KFD_MQD_TYPE type,
429429

430430
switch (type) {
431431
case KFD_MQD_TYPE_CP:
432-
pr_debug("%s@%i\n", __func__, __LINE__);
433432
case KFD_MQD_TYPE_COMPUTE:
434433
pr_debug("%s@%i\n", __func__, __LINE__);
435434
mqd->allocate_mqd = allocate_mqd;

drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,19 @@ void dccg2_init(struct dccg *dccg)
102102
switch (dccg_dcn->base.ctx->dc->res_pool->pipe_count) {
103103
case 6:
104104
REG_UPDATE(DPPCLK_DTO_CTRL, DPPCLK_DTO_DB_EN[5], 1);
105+
/* Fall through */
105106
case 5:
106107
REG_UPDATE(DPPCLK_DTO_CTRL, DPPCLK_DTO_DB_EN[4], 1);
108+
/* Fall through */
107109
case 4:
108110
REG_UPDATE(DPPCLK_DTO_CTRL, DPPCLK_DTO_DB_EN[3], 1);
111+
/* Fall through */
109112
case 3:
110113
REG_UPDATE(DPPCLK_DTO_CTRL, DPPCLK_DTO_DB_EN[2], 1);
114+
/* Fall through */
111115
case 2:
112116
REG_UPDATE(DPPCLK_DTO_CTRL, DPPCLK_DTO_DB_EN[1], 1);
117+
/* Fall through */
113118
case 1:
114119
REG_UPDATE(DPPCLK_DTO_CTRL, DPPCLK_DTO_DB_EN[0], 1);
115120
break;

0 commit comments

Comments
 (0)