The Linux Kernel Is Close To Enabling "-Wimplicit-fallthrough" By Default
Written by Michael Larabel in Linux Kernel on 11 May 2019 at 12:03 AM EDT. 18 Comments
LINUX KERNEL --
The -Wimplicit-fallthrough compiler flag has been around since GCC 7 for warning over switch fall-through cases where it could lead to potential bugs / unexpected behavior if the programmer inadvertently forgot to add a "break" statement to a case. The Linux kernel is looking to soon enable this warning by default.

The -Wimplicit-fallthrough warning tries to be smart about its handling and only warn the programmer/user when appropriate and acknowledging cases where a switch case fall-through would be desirable. Newer Linux kernel developer Gustavo A. R. Silva has been working through more than two thousand warnings from this implicit-fallthrough compiler flag. Of 2,311 cases currently in the kernel where warnings have been emitted, only 32 are left to be gone through to determine if there is any code bugs or a false positive.

In the process a number of bugs have been addressed thanks to this compiler warning, some of which bugs have lasted in the mainline kernel for more than five years. Once addressing the remaining cases, the plan is to enable "-Wimplicit-fallthrough" by default in future kernel builds to prevent similar bugs from creeping into the kernel in the future.

More details on this effort via this pull request for Linux 5.2 that is marking more switch-fallthroughs as expected.

Those unfamiliar with this GCC compiler warning can learn more via this Red Hat developer blog post.
About The Author
Author picture

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 10,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 or contacted via MichaelLarabel.com.

Related Linux Kernel News
Popular News This Week