Linux 5.9 Lands Patch Adding Fallthrough Macro In 2,484 More Spots

Written by Michael Larabel in Linux Kernel on 25 August 2020 at 12:09 PM EDT. 18 Comments
LINUX KERNEL
A single patch coming in at nearly three thousand lines was merged on Monday for the Linux 5.9 kernel that make the use of the "fallthrough" macro more widespread throughout the kernel.

The single patch at large went through and added nearly twenty-five hundred "fallthrough;" lines of code to the kernel to replace existing areas just using a "fall through" code comment or the like. Previously there were just 1,167 references in the kernel using this macro while now it's at more than thirty-six hundred for Linux 5.9.

The fallthrough macro is used for acknowledging the intended flow within switch statements and that the developer didn't simply forget to "break" prior to the next switch case. While there is [[fallthrough]] with C17/C18, until that syntax is more widely supported by C compilers the Linux kernel has its own "fallthrough;" macro. That macro expands to GCC's __attribute__((__fallthrough_)). By using that fallthrough attribute, it ensures the compiler won't emit a warning when compiling the code with the -Wimplicit-fallthrough switch that otherwise will warn when encountering switch case statements that don't break or fallthrough.

So with this patch now queued in the post-RC2 Linux 5.9 kernel there is the mass conversion to using this pseudo-keyword. A few areas remain for switching to fallthrough where the patches were sent out independently to the different kernel subsystems, but those areas too should be cleaned up in the near future.

Besides this code improvement, there are many new features coming with Linux 5.9. Linux 5.9 stable should be out in October.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week