From: Tom Rini Date: Tue, 8 Apr 2025 22:24:12 +0000 (-0600) Subject: Merge patch series "Annotate switch/case fallthrough cases" X-Git-Tag: v2025.07-rc1~108 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f0281294d8bb1857076d27fd491c70c9808e474;p=pandora-u-boot.git Merge patch series "Annotate switch/case fallthrough cases" Andre Przywara says: 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 note that those patches do not fix anything, really, they just add those fallthrough annotations, so the series is not really critical. Link: https://lore.kernel.org/r/20250327153313.2105227-1-andre.przywara@arm.com --- 1f0281294d8bb1857076d27fd491c70c9808e474 diff --cc lib/tiny-printf.c index da2063d27c9,b8fc8355c4a..2a7a4d286c0 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@@ -283,9 -282,8 +283,9 @@@ static int _vprintf(struct printf_info break; } islong = true; - /* no break */ + fallthrough; case 'x': + case 'X': if (islong) { num = va_arg(va, unsigned long); div = 1UL << (sizeof(long) * 8 - 4);