U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] Annotate switch/case fallthrough cases
@ 2025-03-27 15:32 Andre Przywara
  2025-03-27 15:32 ` [PATCH 01/18] spl: mmc: properly annotate fallthrough Andre Przywara
                   ` (19 more replies)
  0 siblings, 20 replies; 44+ messages in thread
From: Andre Przywara @ 2025-03-27 15:32 UTC (permalink / raw)
  To: Tom Rini, Simon Glass
  Cc: Marek Vasut, Michal Simek, Heinrich Schuchardt, Ilias Apalodimas,
	u-boot, Ramon Fried, Joe Hershberger, Mattijs Korpershoek,
	Bin Meng, Anatolij Gustschin, Kyungmin Park, Heiko Schocher,
	Jagan Teki, Vignesh R, Tudor Ambarus, Dario Binacchi,
	Michael Trimarchi

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.

Because of this we cannot quite enable the warning in the Makefile yet,
but those fixes are worth regardless, and be it to increase readability.

Please not that those patches do not fix anything, really, they just add
those fallthrough annotations, so the series is not really critical.

Cheers,
Andre

Andre Przywara (18):
  spl: mmc: properly annotate fallthrough
  zlib: annotate switch/case fallthrough cases
  gadget: f_thor: annotate switch/case fallthrough
  use proper fallthrough annotations
  net/net: fix switch/case fallthrough annotations
  fastboot: annotate switch/case fallthrough case
  net: sun8i-emac: annotate fallthrough
  usb: ohci-hcd: annotate switch/case fallthrough
  usb: xhci: annotate switch/case fallthrough properly (TBF)
  video: annotate switch/case fall-through
  net: e1000: annotate switch/case fallthrough
  mtd: ubi: annotate fallthrough (TBF)
  arm: mach-k3: am62p: annotate switch/case fallthrough
  mtd: spi-nor-tiny: annotate switch/case fallthrough
  mtd: rawnand: nand_base: annotate switch/case fallthrough
  cmd: pmic: annotate switch/case fallthrough
  cmd: spl: annotate switch/case fallthrough
  [DO NOT MERGE] Makefile: enable switch/case fallthrough warnings

 Makefile                              |  1 +
 arch/arm/mach-k3/am62px/am62p5_init.c |  1 +
 cmd/pmic.c                            |  1 +
 cmd/spl.c                             |  2 ++
 common/command.c                      |  2 +-
 common/spl/spl_mmc.c                  |  1 +
 drivers/fastboot/fb_command.c         |  1 +
 drivers/mtd/nand/raw/nand_base.c      |  4 ++++
 drivers/mtd/spi/spi-nor-tiny.c        |  1 +
 drivers/mtd/ubi/attach.c              |  1 +
 drivers/mtd/ubi/build.c               |  3 +++
 drivers/net/e1000.c                   |  2 ++
 drivers/net/sun8i_emac.c              |  1 +
 drivers/usb/gadget/f_thor.c           |  1 +
 drivers/usb/host/ohci-hcd.c           |  3 ++-
 drivers/usb/host/xhci.c               |  2 +-
 drivers/video/video-uclass.c          |  2 ++
 lib/tiny-printf.c                     |  2 +-
 lib/zlib/inflate.c                    | 21 +++++++++++++++++++++
 net/net.c                             |  5 ++---
 20 files changed, 50 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2025-04-10  1:47 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-04-10  1:46 ` (subset) " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox