Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jan 2021 21:56:14 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        Ryan Libby <rlibby@freebsd.org>, Vladimir Kondratyev <wulf@freebsd.org>, John Baldwin <jhb@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 16079c7233be - main - hid: quiet -Wswitch
Message-ID:  <4a6b1780-b3df-29f7-6062-05c6e81231da@selasky.org>
In-Reply-To: <CAHgpiFxxWvskdf9PyDkB4mhf6c=%2BBKGnhVMH1iTLB6su_tzqXg@mail.gmail.com>
References:  <202101110554.10B5sW2q070743@gitrepo.freebsd.org> <700dd42d-2d73-e54a-5fcc-b62ed31df80d@FreeBSD.org> <CAHgpiFxxWvskdf9PyDkB4mhf6c=%2BBKGnhVMH1iTLB6su_tzqXg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4a6b1780-b3df-29f7-6062-05c6e81231da>