From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>
Subject: Re: [dpdk-kmods] linux/igb_uio: fix build for switch fall through
Date: Thu, 16 Dec 2021 09:37:58 +0000 [thread overview]
Message-ID: <4fc78021-270a-39c1-b238-399fd4e98f85@intel.com> (raw)
In-Reply-To: <20211215151546.40de01c3@hermes.local>
On 12/15/2021 11:15 PM, Stephen Hemminger wrote:
> On Wed, 15 Dec 2021 21:04:30 +0000
> Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
>> On 12/15/2021 7:20 PM, Stephen Hemminger wrote:
>>> On Wed, 15 Dec 2021 18:48:59 +0000
>>> Ferruh Yigit <ferruh.yigit@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@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.
>
> Your right, on older kernels it really is just a dummy statement.
> The regex can't work, you can take (or leave the comment) it has no effect
> because implicit-fallthrough won't see it in a macro.
True, it has no benefit for 'Wimplicit-fallthrough', and regex doesn't hit.
But for the old kernels (<= 5.3) still need to have this define to prevent
build error, because they are missing 'fallthrough' macro.
But for those kernels, '-Wimplicit-fallthrough' compiler option is not
set, so that should be OK **.
I have tested with '4.19.221' stable kernel, this change builds fine.
**: Only v5.3 has potential problem, which defines '-Wimplicit-fallthrough' and
doesn't define the 'fallthrough' macro. When igb_uio compiled with this version
'fallthrough' is dummy statement from 'compat.h' and '-Wimplicit-fallthrough'
can cause warning.
To fix this, I will move both dummy and attribute macro definition to compat.h
next prev parent reply other threads:[~2021-12-16 9:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 18:48 Ferruh Yigit
2021-12-15 19:20 ` Stephen Hemminger
2021-12-15 21:04 ` Ferruh Yigit
2021-12-15 23:15 ` Stephen Hemminger
2021-12-16 9:37 ` Ferruh Yigit [this message]
2021-12-16 12:03 ` [dpdk-kmods v2] " Ferruh Yigit
2022-01-11 14:32 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4fc78021-270a-39c1-b238-399fd4e98f85@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).