gcc -Wall will complain when we fallthrough on a switch but don't mean it. Fortunately we can follow the Linux kernel strategy to use -Wimplicit-fallthrough=2 and allow comments to supress this to clarify this was intended. Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx> --- Makefile.in | 4 +++- snprintf.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index da2fc96..ef414a5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,6 +16,8 @@ DESTDIR=/ CC=@CC@ CFLAGS=@CFLAGS@ -I. -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(datadir)\" CFLAGS+=`pkg-config --cflags libtirpc` +# Allows comments to be used for fallthrough +CFLAGS+=-Wimplicit-fallthrough=2 CFLAGS_RPCGEN=-Wno-unused-variable LIBS+=`pkg-config --libs libtirpc` EXEEXT=@EXEEXT@ @@ -28,7 +30,7 @@ SRV_OBJS = util.o tbench_srv.o socklib.o all: dbench doc dbench: $(DB_OBJS) - $(CC) -o $@ $(DB_OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(DB_OBJS) $(LIBS) tbench_srv: $(SRV_OBJS) $(CC) -o $@ $(SRV_OBJS) $(LIBS) diff --git a/snprintf.c b/snprintf.c index adfd3c4..9cfc20e 100644 --- a/snprintf.c +++ b/snprintf.c @@ -317,6 +317,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case 'X': flags |= DP_F_UP; + /* fallthrough */ case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) @@ -339,6 +340,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case 'E': flags |= DP_F_UP; + /* fallthrough */ case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); @@ -348,6 +350,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case 'G': flags |= DP_F_UP; + /* fallthrough */ case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); -- 2.34.1