Skip to content

Annotate switch/case fallthrough cases

Andre Przywara u-boot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest18 patches 25 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18spl: mmc: properly annotate fallthroughcommon/spl/spl_mmc.c+1 -01 reply
2/18zlib: annotate switch/case fallthrough caseslib/zlib/inflate.c+21 -01 reply
3/18gadget: f_thor: annotate switch/case fallthroughdrivers/usb/gadget/f_thor.c+1 -01 reply
4/18use proper fallthrough annotationscommon/command.c lib/tiny-printf.c net/net.c+3 -31 reply
5/18net/net: fix switch/case fallthrough annotationsnet/net.c+1 -26 replies
6/18fastboot: annotate switch/case fallthrough casedrivers/fastboot/fb_command.c+1 -01 reply
7/18net: sun8i-emac: annotate fallthroughdrivers/net/sun8i_emac.c+1 -00 replies
8/18usb: ohci-hcd: annotate switch/case fallthroughdrivers/usb/host/ohci-hcd.c+2 -10 replies
9/18usb: xhci: annotate switch/case fallthrough properlydrivers/usb/host/xhci.c+1 -11 reply
10/18video: annotate switch/case fall-throughdrivers/video/video-uclass.c+2 -01 reply
11/18net: e1000: annotate switch/case fallthroughdrivers/net/e1000.c+2 -00 replies
12/18mtd: ubi: annotate fallthroughdrivers/mtd/ubi/attach.c drivers/mtd/ubi/build.c+4 -01 reply
13/18arm: mach-k3: am62p: annotate switch/case fallthrougharch/arm/mach-k3/am62px/am62p5_init.c+1 -01 reply
14/18mtd: spi-nor-tiny: annotate switch/case fallthroughdrivers/mtd/spi/spi-nor-tiny.c+1 -01 reply
15/18mtd: rawnand: nand_base: annotate switch/case fallthroughdrivers/mtd/nand/raw/nand_base.c+4 -01 reply
16/18cmd: pmic: annotate switch/case fallthroughcmd/pmic.c+1 -01 reply
17/18cmd: spl: annotate switch/case fallthroughcmd/spl.c+2 -01 reply
18/18Makefile: enable switch/case fallthrough warningsMakefile+1 -01 reply

Reviews trailers per patch

14 of 18 patches have a Reviewed-by or Acked-by.

PatchHeiko SchocherMichael TrimrachiTom RiniMattijs Korpershoek
1/18R-b
2/18R-b
3/18R-b
4/18R-b
5/18R-b
6/18R-b
7/18
8/18
9/18R-b
10/18R-b
11/18
12/18R-b
13/18R-b
14/18R-b
15/18R-b
16/18R-b
17/18R-b
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/18] Annotate switch/case fallthrough cases

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(-)
Signature · 1 line
2.25.1