Linux 5.9 Lands Patch Adding Fallthrough Macro In 2,484 More Spots
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.
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.
18 Comments