U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>, Marek Vasut <marex@denx.de>,
	Michal Simek <michal.simek@amd.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	u-boot@lists.denx.de
Subject: Re: [PATCH 05/18] net/net: fix switch/case fallthrough annotations
Date: Wed, 9 Apr 2025 00:53:47 +0100	[thread overview]
Message-ID: <20250409005347.04003b4b@minigeek.lan> (raw)
In-Reply-To: <20250408222918.GA1475540@bill-the-cat>

On Tue, 8 Apr 2025 16:29:18 -0600
Tom Rini <trini@konsulko.com> wrote:

Hi Tom,

thanks for staying on this!

> On Thu, Mar 27, 2025 at 03:33:00PM +0000, Andre Przywara wrote:
> 
> > The net_check_prereq() routine in the generic network handling code
> > mixes case: labels with #ifdef's, which makes predicting fallthrough
> > situations tricky. We had two "fall through" comments in the code, but
> > at the wrong places.
> > 
> > Remove one unneeded comment (no annotations necessary between just empty
> > labels), and move one other instance to the right place (before any
> > label sequence).
> > This makes GCC's implicit fallthrough checker happy.
> > 
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > Reviewed-by: Tom Rini <trini@konsulko.com>
> > ---
> >  net/net.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/net/net.c b/net/net.c
> > index 5219367e391..f191f16357c 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -1525,7 +1525,6 @@ static int net_check_prereq(enum proto_t protocol)
> >  #if defined(CONFIG_CMD_NFS)
> >  	case NFS:
> >  #endif
> > -		/* Fall through */
> >  	case TFTPGET:
> >  	case TFTPPUT:
> >  		if (IS_ENABLED(CONFIG_IPV6) && use_ip6) {
> > @@ -1539,11 +1538,11 @@ static int net_check_prereq(enum proto_t protocol)
> >  			puts("*** ERROR: `serverip' not set\n");
> >  			return 1;
> >  		}
> > +		fallthrough;
> >  #if	defined(CONFIG_CMD_PING) || \
> >  	defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP)
> >  common:
> >  #endif
> > -		/* Fall through */
> >  
> >  	case NETCONS:
> >  	case FASTBOOT_UDP:  
> 
> So this one is harder than it looks. With clang, we cannot seemingly
> have:
> 	fallthrough;
> #if defined(CONFIG_CMD_PING) || \
>     defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP)
> common:
> #endif
> 
> And gcc was failing on:
> 	}
> #if defined(CONFIG_CMD_PING) || \
>     defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP)
> common:
> #endif
> 	fallthrough;

Yes, later stages of the CI told me so already ;-)

> Maybe we can move the label to inside the next set of cases, and then
> also add CONFIG_CMD_PING6 to the checks, as that also has 'goto common;'

I found some other solution: dropping the #if's around the common:
label, then marking this with __maybe_unused instead. Seems to work for
both GCC and clang, and makes the code even more readable.

Will send this among the other gazillion fixes I meanwhile added in a
v2, to a mailbox near you.
If you can't wait: sunxi/fallthrough has the bits, though not yet split
up and without commit messages. Still not passing all checks, but the
CI builds seem to stop early, before revealing all issues, so this is a
piecemeal job :-(

Cheers,
Andre

  reply	other threads:[~2025-04-08 23:54 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 [this message]
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
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=20250409005347.04003b4b@minigeek.lan \
    --to=andre.przywara@arm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=joe.hershberger@ni.com \
    --cc=marex@denx.de \
    --cc=michal.simek@amd.com \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --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