[Intel-gfx] [PATCH] drm/i915: mark expected switch fall-through
Jani Nikula
jani.nikula at linux.intel.com
Thu Jun 21 08:03:14 UTC 2018
On Wed, 20 Jun 2018, "Gustavo A. R. Silva" <gustavo at embeddedor.com> wrote:
> On 06/20/2018 02:06 PM, Rodrigo Vivi wrote:
>> On Wed, Jun 20, 2018 at 08:31:00AM -0500, Gustavo A. R. Silva wrote:
>>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>>> where we are expecting to fall through.
>>>
>>> Addresses-Coverity-ID: 1470102 ("Missing break in switch")
>>
>> Any other advantage besides coverity?
>> Can't we address it by marking as "Intentional" on the tool?
>>
>
> Yes. The advantage of this is that it will eventually allows to enable
> -Wimplicit-fallthrough, hence, enabling the compiler to trigger a
> warning, which will force us to double check if we are actually missing
> a break before committing the code.
I applaud the efforts. Since you're doing the comment changes, do you
have an idea what -Wimplicit-fallthrough=N level is being considered for
kernel?
>> I'm afraid there will be so many more places to add fallthrough
>> marks....
>>
>
> Oh yeah, there are around 1000 similar places in the whole codebase.
> There is an ongoing effort to review each case. Months ago, it used to
> be around 1500 of these cases.
We use our own MISSING_CASE() to indicate stuff that's not supposed to
happen, or to be implemented, etc. and in many cases the fallthrough is
normal. I wonder if we could embed __attribute__ ((fallthrough)) in
there to tackle all of these without a comment.
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
More information about the dri-devel
mailing list