Makefile: Globally enable fall-through warning
Subsystems (3)
PATCH 1/1 Makefile: Globally enable fall-through warning
From: "Gustavo A. R. Silva" <[email protected]>
Now that all the fall-through warnings have been addressed in the kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through as 'deprecated' so people can be pointed to a single location for justification.
--- Documentation/process/deprecated.rst | 14 ++++++++++++++ Makefile | 3 +++ 2 files changed, 17 insertions(+)
Documentation/process/deprecated.rst +14 -0
@@ -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.
Makefile +3 -0
@@ -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
Signature · 1 line
2.52.0
Randy Dunlap
reviewerHi,
Quoted 9 lines · Simone Rea
From: "Gustavo A. R. Silva" <[email protected]>
Now that all the fall-through warnings have been addressed in the kernel, enable the fall-through warning globally.
Also, update the
deprecated.rstfile to include implicit fall-through as 'deprecated' so people can be pointed to a single location for justification.
Quoted 6 lines
Cc Masahiro Yamada <[email protected]>Cc Andrew Morton <[email protected]>Cc Michal Marek <[email protected]>Cc Kees Cook <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
This is missing your Signed-off-by: line. See Documentation/process/submitting-patches.rst for info.
Also you should copy the current KBUILD maintainers. See the MAINTAINERS file.
Quoted 17 lines
--- Documentation/process/deprecated.rst | 14 ++++++++++++++ Makefile | 3 +++ 2 files changed, 17 insertions(+)Documentation/process/deprecated.rst +4
-0@@ -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
Documentation/process/deprecated.rst array may exceed the remaining memory in the stack segment. This could · line 135
Quoted 10 lines
Documentation/process/deprecated.rst +10
-0+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.
Given that we have 80 cases of
/* Fall through */ or /* fall through */ in the kernel tree and we have over 5000 cases of fallthrough;
ITSM that you could go ahead and call for using the latter.
Quoted 14 lines
Makefile +3
-0@@ -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
Signature · 1 line
~Randy
Quoted 17 lines · On Thu, 22 Jan 2026 10:19:56 -0800 Randy Dunlap <[email protected]> wrote:
Quoted 9 lines · Simone Rea
From: "Gustavo A. R. Silva" <[email protected]>
Now that all the fall-through warnings have been addressed in the kernel, enable the fall-through warning globally.
Also, update the
deprecated.rstfile to include implicit fall-through as 'deprecated' so people can be pointed to a single location for justification.Quoted 6 lines
Cc Masahiro Yamada <[email protected]>Cc Andrew Morton <[email protected]>Cc Michal Marek <[email protected]>Cc Kees Cook <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
Quoted 5 lines
This is missing your Signed-off-by: line. See
Documentation/process/submitting-patches.rstfor info.Also you should copy the current KBUILD maintainers. See the
MAINTAINERSfile.
This went into mainline in 2019 :) I suspect Gustavo had a slight IT problem.
Randy Dunlap
reviewerQuoted 19 lines · Andrew Morton
Quoted 17 lines · On Thu, 22 Jan 2026 10:19:56 -0800 Randy Dunlap <[email protected]> wrote:
Quoted 15 lines · Simone Rea
From: "Gustavo A. R. Silva" <[email protected]>
Now that all the fall-through warnings have been addressed in the kernel, enable the fall-through warning globally.
Also, update the
deprecated.rstfile to include implicit fall-through as 'deprecated' so people can be pointed to a single location for justification.Cc Masahiro Yamada <[email protected]>Cc Andrew Morton <[email protected]>Cc Michal Marek <[email protected]>Cc Kees Cook <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
Quoted 8 lines
Quoted 5 lines
This is missing your Signed-off-by: line. See
Documentation/process/submitting-patches.rstfor info.Also you should copy the current KBUILD maintainers. See the
MAINTAINERSfile.This went into mainline in 2019 :) I suspect Gustavo had a slight IT problem.
I think Simone did.
Signature · 1 line
~Randy
Quoted 2 lines · Randy Dunlap
I think Simone did.
Yeah, I don't know what is going on with that particular patch, but someone sent the same one earlier this month:
https://lore.kernel.org/all/[email protected]/
Maybe an assignment?
Cheers,
Miguel
A message that is not in the archive (sent off-list or not yet received): CAEfWggNK7DgsRHXTE8BhWCTuDKyt6pMR_9UEHEs1NKPfPPyopw@mail.gmail.com
Quoted 2 lines · Simone Rea
Guys I’m so sorry 🙏🙏🙏 I don’t know what I did, i’m justinf following a tutorial…
This is the second time someone submit this same patch by mistake.
I'm curious about that tutorial. Can you please share with us a link to it?
Who's the author?
Are you paying for it?
Thanks
-Gustavo
Quoted 43 lines
Il giorno gio 22 gen 2026 alle 19:46 Randy Dunlap <[email protected]> ha scritto:
Quoted 38 lines · Andrew Morton
Quoted 1 line
On Thu, 22 Jan 2026 10:19:56 -0800 Randy Dunlap <[email protected]>
Quoted 18 lines · wrote:
Quoted 18 lines · Simone Rea
Quoted 15 lines
From: "Gustavo A. R. Silva" <[email protected]>
Now that all the fall-through warnings have been addressed in the kernel, enable the fall-through warning globally.
Also, update the
deprecated.rstfile to include implicit fall-through as 'deprecated' so people can be pointed to a single location for justification.Cc Masahiro Yamada <[email protected]>Cc Andrew Morton <[email protected]>Cc Michal Marek <[email protected]>Cc Kees Cook <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>Quoted 8 lines
Quoted 5 lines
This is missing your Signed-off-by: line. See
Documentation/process/submitting-patches.rstfor info.Also you should copy the current KBUILD maintainers. See the
MAINTAINERSfile.This went into mainline in 2019 :) I suspect Gustavo had a slight IT problem.
I think Simone did.
--
~Randy