From: Tom Rini <trini@konsulko.com>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>, Marek Vasut <marex@denx.de>,
Michal Simek <michal.simek@amd.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
u-boot@lists.denx.de, Ramon Fried <rfried.dev@gmail.com>,
Joe Hershberger <joe.hershberger@ni.com>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Bin Meng <bmeng.cn@gmail.com>, Anatolij Gustschin <agust@denx.de>,
Kyungmin Park <kmpark@infradead.org>, Heiko Schocher <hs@denx.de>,
Jagan Teki <jagan@amarulasolutions.com>,
Vignesh R <vigneshr@ti.com>,
Tudor Ambarus <tudor.ambarus@linaro.org>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Michael Trimarchi <michael@amarulasolutions.com>
Subject: Re: [PATCH 00/18] Annotate switch/case fallthrough cases
Date: Fri, 28 Mar 2025 07:49:47 -0600 [thread overview]
Message-ID: <20250328134947.GT93000@bill-the-cat> (raw)
In-Reply-To: <20250328134554.496fb357@donnerap.manchester.arm.com>
[-- Attachment #1: Type: text/plain, Size: 2643 bytes --]
On Fri, Mar 28, 2025 at 01:45:54PM +0000, Andre Przywara wrote:
> On Fri, 28 Mar 2025 10:39:59 +0000
> Andre Przywara <andre.przywara@arm.com> wrote:
>
> Hi,
>
> > On Fri, 28 Mar 2025 11:28:05 +0100
> > Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> >
> > Hi,
> >
> > > On 27.03.25 16:32, Andre Przywara wrote:
> > > > C's implicit fallthrough behaviour in switch/case statements can lead to
> > > > subtle bugs. Quite some while ago many compilers introduced warnings in
> > > > those cases, requiring intentional fallthrough's to be annotated.
> > > >
> > > > So far we were not enabling that compiler option, so many ambiguities
> > > > and some bugs in the code went unnoticed.
> > > >
> > > > This series adds the required annotations in code paths that the first
> > > > stage of the U-Boot CI covers. There is a large number of cases left
> > > > in the libbz2 code. The usage of switch/case is borderline insane there,
> > > > labels are hidden in macros, and there are no breaks, but just goto's.
> > > > Upstream still uses very similar code, without any annotations. I still
> > > > am not 100% sure those are meant to fall through or not, and plan to do
> > > > further investigations, but didn't want to hold the rest of the patches
> > > > back. You can see for yourself by applying patch 18/18 and building for
> > > > sandbox64, for instance.
> > >
> > > Can we use something like
> > >
> > > CFLAGS_REMOVE_bzlib.o = -Wimplicit-fallthrough
> >
> > Ah, didn't know we have that in U-Boot as well! Sounds promising, and
> > fixes the sandbox build for me (when using bzlib_decompress.o). I will add
> > this to the last patch and will check what the CI has to say about this.
>
> So for the records: silencing the libbzip2 warnings uncovered a whole new
> bunch of warnings, in stage 1 still. Some compilers used in the CI (clang?)
> seem to be more picky about how to annotate, so a pure comment (/* fall
> through */) would not cut it, it has to be the attribute - provided by our
> "statement macro".
> So I fixed those quickly, stuffed them into some patch, and now the first
> CI stage (test.py) passes - but only to uncover a large number of new
> warnings in the world build.
> So I will keep on patching, as some kind of procrastination project ;-)
So, for the flag, what I would like is to borrow the
CONFIG_CC_IMPLICIT_FALLTHROUGH logic from the kernel. Then we should be
able to do:
CFLAGS_REMOVE_bzlib.o += $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
I think.
Then as follow-up convert any of our just /* fallthrough */ to
'fallthrough;'.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2025-03-28 13:49 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 15:32 [PATCH 00/18] Annotate switch/case fallthrough cases Andre Przywara
2025-03-27 15:32 ` [PATCH 01/18] spl: mmc: properly annotate fallthrough Andre Przywara
2025-03-29 0:06 ` Tom Rini
2025-03-27 15:32 ` [PATCH 02/18] zlib: annotate switch/case fallthrough cases Andre Przywara
2025-03-31 16:13 ` Tom Rini
2025-03-27 15:32 ` [PATCH 03/18] gadget: f_thor: annotate switch/case fallthrough Andre Przywara
2025-03-31 8:01 ` Mattijs Korpershoek
2025-03-27 15:32 ` [PATCH 04/18] use proper fallthrough annotations Andre Przywara
2025-03-31 14:11 ` Tom Rini
2025-03-27 15:33 ` [PATCH 05/18] net/net: fix switch/case " Andre Przywara
2025-03-31 15:55 ` Tom Rini
2025-04-08 22:29 ` Tom Rini
2025-04-08 23:53 ` Andre Przywara
2025-04-09 1:46 ` Tom Rini
2025-04-09 10:41 ` Andre Przywara
2025-04-09 14:15 ` Tom Rini
2025-03-27 15:33 ` [PATCH 06/18] fastboot: annotate switch/case fallthrough case Andre Przywara
2025-03-31 8:04 ` Mattijs Korpershoek
2025-03-27 15:33 ` [PATCH 07/18] net: sun8i-emac: annotate fallthrough Andre Przywara
2025-03-27 15:33 ` [PATCH 08/18] usb: ohci-hcd: annotate switch/case fallthrough Andre Przywara
2025-03-27 15:33 ` [PATCH 09/18] usb: xhci: annotate switch/case fallthrough properly Andre Przywara
2025-03-31 15:57 ` Tom Rini
2025-03-27 15:33 ` [PATCH 10/18] video: annotate switch/case fall-through Andre Przywara
2025-03-31 16:01 ` Tom Rini
2025-03-27 15:33 ` [PATCH 11/18] net: e1000: annotate switch/case fallthrough Andre Przywara
2025-03-27 15:33 ` [PATCH 12/18] mtd: ubi: annotate fallthrough Andre Przywara
2025-03-28 5:03 ` Heiko Schocher
2025-03-27 15:33 ` [PATCH 13/18] arm: mach-k3: am62p: annotate switch/case fallthrough Andre Przywara
2025-03-31 14:11 ` Tom Rini
2025-03-27 15:33 ` [PATCH 14/18] mtd: spi-nor-tiny: " Andre Przywara
2025-03-31 16:07 ` Tom Rini
2025-03-27 15:33 ` [PATCH 15/18] mtd: rawnand: nand_base: " Andre Przywara
2025-03-28 8:26 ` Michael Nazzareno Trimarchi
2025-03-27 15:33 ` [PATCH 16/18] cmd: pmic: " Andre Przywara
2025-03-31 16:09 ` Tom Rini
2025-03-27 15:33 ` [PATCH 17/18] cmd: spl: " Andre Przywara
2025-03-31 16:09 ` Tom Rini
2025-03-27 15:33 ` [PATCH 18/18] [DO NOT MERGE] Makefile: enable switch/case fallthrough warnings Andre Przywara
2025-03-28 16:07 ` Tom Rini
2025-03-28 10:28 ` [PATCH 00/18] Annotate switch/case fallthrough cases Heinrich Schuchardt
2025-03-28 10:39 ` Andre Przywara
2025-03-28 13:45 ` Andre Przywara
2025-03-28 13:49 ` Tom Rini [this message]
2025-04-10 1:46 ` (subset) " Tom Rini
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=20250328134947.GT93000@bill-the-cat \
--to=trini@konsulko.com \
--cc=agust@denx.de \
--cc=andre.przywara@arm.com \
--cc=bmeng.cn@gmail.com \
--cc=dario.binacchi@amarulasolutions.com \
--cc=hs@denx.de \
--cc=ilias.apalodimas@linaro.org \
--cc=jagan@amarulasolutions.com \
--cc=joe.hershberger@ni.com \
--cc=kmpark@infradead.org \
--cc=marex@denx.de \
--cc=michael@amarulasolutions.com \
--cc=michal.simek@amd.com \
--cc=mkorpershoek@baylibre.com \
--cc=rfried.dev@gmail.com \
--cc=sjg@chromium.org \
--cc=tudor.ambarus@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
--cc=xypron.glpk@gmx.de \
/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