[SLOF] [PATCH] Compile SLOF with -Wimplicit-fallthrough
Thomas Huth
thuth at redhat.com
Sun Jan 24 17:54:37 AEDT 2021
The -Wimplicit-fallthrough warnings help to catch bugs with forgotten
"break" statements, so it's a good idea to have this switch enabled.
Thus let's fix the current spots that generate warnings and add the
switch to our WARNFLAGS.
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
lib/libc/stdio/vsnprintf.c | 1 +
make.rules | 4 +++-
slof/prim.code | 3 +++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c
index 21dd04d..23e6dd4 100644
--- a/lib/libc/stdio/vsnprintf.c
+++ b/lib/libc/stdio/vsnprintf.c
@@ -163,6 +163,7 @@ print_format(char **buffer, size_t bufsize, const char *format, void *var)
break;
case 'X':
upper = true;
+ /* fallthrough */
case 'x':
sizec[i] = '\0';
value = (unsigned long) var & convert[length_mod];
diff --git a/make.rules b/make.rules
index 3dfbb5b..a66f9be 100644
--- a/make.rules
+++ b/make.rules
@@ -76,7 +76,9 @@ AR ?= $(CROSS)ar
RANLIB ?= $(CROSS)ranlib
CPP ?= $(CROSS)cpp
-WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security
+WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security \
+ -Wimplicit-fallthrough
+
CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \
-fno-strict-aliasing -mno-altivec -mabi=no-altivec \
-fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS)
diff --git a/slof/prim.code b/slof/prim.code
index bb9e036..b9db151 100644
--- a/slof/prim.code
+++ b/slof/prim.code
@@ -469,18 +469,21 @@ code_FILL:
#endif
while ((size-=sizeof(type_u)) >= 0)
*up++ = fill_v;
+ break;
}
case sizeof(type_l): {
type_l *lp = (type_l *)d;
while ((size-=sizeof(type_l)) >= 0)
*lp++ = (type_l)fill_v;
+ break;
}
case sizeof(type_w): {
type_w *wp = (type_w *)d;
while ((size-=sizeof(type_w)) >= 0)
*wp++ = (type_w)fill_v;
+ break;
}
default:
while (size-- > 0)
--
2.27.0
More information about the SLOF
mailing list