git: 16079c7233be - main - hid: quiet -Wswitch

Hans Petter Selasky hps at selasky.org
Mon Jan 11 20:56:28 UTC 2021


On 1/11/21 8:05 PM, Ryan Libby wrote:
>> If these cases are never reachable, then I think '__assert_unreachable()'
>> is preferred to a plain break.
>
Hi,

> I'll have to let wulf and hselasky speak to that...

__assert_unreachable() is a bit fresh in my opinion. Basically it comes 
down to a panic/assert when supposedly unreached cases are triggered.

commit c79cee71363ddaeb3c5ab7d3ccb87a11e1860d95
Author: Kyle Evans <kevans at FreeBSD.org>
Date:   Wed May 13 18:07:37 2020 +0000

     kernel: provide panicky version of __unreachable

I think:

default:
  break;

Or when you need:

/* FALLTHROUGH */

is perfectly fine, even though I see other OS'es even macrofy 
FALLTHROUGH as a built in compiler attribute.

Why do a) and not b) ?

Are there more things about switch cases we should do?

--HPS


More information about the dev-commits-src-all mailing list