Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88c50834 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'Wimplicit-fallthrough-5.3-rc2' of...

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
parents 43e317c1 a035d552
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)

Implicit switch case fall-through
---------------------------------
The C language allows switch cases to "fall through" when
a "break" statement is missing at the end of a case. This,
however, introduces ambiguity in the code, as it's not always
clear if the missing break is intentional or a bug. As there
have been a long list of flaws `due to missing "break" statements
<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
"implicit fall-through". In order to identify an intentional fall-through
case, we have adopted the marking used by static analyzers: a comment
saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
is more widely handled by C compilers, static analyzers, and IDEs, we can
switch to using that instead.
+3 −0
Original line number Diff line number Diff line
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement

# Warn about unmarked fall-throughs in switch statement.
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)

# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla

+2 −0
Original line number Diff line number Diff line
@@ -4955,6 +4955,7 @@ __init int intel_pmu_init(void)

	case INTEL_FAM6_SKYLAKE_X:
		pmem = true;
		/* fall through */
	case INTEL_FAM6_SKYLAKE_MOBILE:
	case INTEL_FAM6_SKYLAKE_DESKTOP:
	case INTEL_FAM6_KABYLAKE_MOBILE:
@@ -5004,6 +5005,7 @@ __init int intel_pmu_init(void)
	case INTEL_FAM6_ICELAKE_X:
	case INTEL_FAM6_ICELAKE_XEON_D:
		pmem = true;
		/* fall through */
	case INTEL_FAM6_ICELAKE_MOBILE:
	case INTEL_FAM6_ICELAKE_DESKTOP:
		x86_pmu.late_ack = true;
+1 −1
Original line number Diff line number Diff line
@@ -957,7 +957,7 @@ static void set_broadcast_channel(struct fw_device *device, int generation)
				device->bc_implemented = BC_IMPLEMENTED;
				break;
			}
			/* else fall through to case address error */
			/* else, fall through - to case address error */
		case RCODE_ADDRESS_ERROR:
			device->bc_implemented = BC_UNIMPLEMENTED;
		}
+1 −1
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
			if ((data[0] & bit) == (data[1] & bit))
				continue;

			/* 1394-1995 IRM, fall through to retry. */
			/* fall through - It's a 1394-1995 IRM, retry. */
		default:
			if (retry) {
				retry--;
Loading