[dpdk-kmods] linux/igb_uio: fix build for switch fall through
Ferruh Yigit
ferruh.yigit at intel.com
Wed Dec 15 22:04:30 CET 2021
On 12/15/2021 7:20 PM, Stephen Hemminger wrote:
> On Wed, 15 Dec 2021 18:48:59 +0000
> Ferruh Yigit <ferruh.yigit at intel.com> wrote:
>
>> Linux is using '-Wimplicit-fallthrough=5' compiler option, which doesn't
>> take any fall through comments into account but only uses compiler
>> 'fallthrough' attribute to document fall through action is intended.
>>
>> "falls through" comment was used in the code which is causing a build
>> error now, this patch converts comment to the 'fallthrough' macro
>> defined in the Linux.
>>
>> To cover the case where Linux version doesn't have the macro, defined it
>> in the compatibility header too.
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit at intel.com>
>
> Are you sure that fixes it? because the comment in the macro is typically
> not visible in a macro expansion.
> Since in most case Linux uses gcc why not use the gcc attribute
>
> __attribute__ ((fallthrough))
Hi Stephen,
That is the intention already.
Patch is using the Linux kernel defined macro:
#if __has_attribute(__fallthrough__)
# define fallthrough __attribute__((__fallthrough__))
#else
# define fallthrough do {} while (0) /* fallthrough */
#endif
And it builds fine without the macro in the 'compat.h'.
I added the define in the 'compat.h' for old kernels which doesn't
define the macro. For that case I expect default '-Wimplicit-fallthrough'
option is used which accepts 'fallthrough;' as a regex hit.
More information about the dev
mailing list