Makefile.inc: Enable -Wextra and -Wformat-nonliteral
Hi Bart,
With this patch, clang is emitting four new warnings:
Makefile.inc
Quoted 13 lines
Instead of selecting some of the options enabled by -Wextra, enable
(quoted diff) +0
-2-Wextra and disable some of the options enabled by -Wextra. Enable -Wformat-nonliteral.Makefile.inc +4
-2-OPTFLAGS = -Wunused -Wstrict-prototypes -O2 -g -pipe -Wformat-security -Wall \ - -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 +OPTFLAGS = -O2 -g -pipe -Wall -Wextra -Wformat=2 \ + -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered\ + -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector \ + --param=ssp-buffer-size=4
clang -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmpathcmd -DUSE_SYSTEMD=229 -DLIBDM_API_FLUSH -D_GNU_SOURCE -DLIBDM_API_COOKIE -DLIBUDEV_API_RECVBUF -DLIBDM_API_DEFERRED -c -o devmapper.o devmapper.c
devmapper.c:86:20: warning: format string is not a string literal [-Wformat-nonliteral]
vfprintf(stdout, f, ap);
^1 warning generated.
clang -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmpathcmd -DUSE_SYSTEMD=229 -DLIBDM_API_FLUSH -D_GNU_SOURCE -DLIBDM_API_COOKIE -DLIBUDEV_API_RECVBUF -DLIBDM_API_DEFERRED -c -o debug.o debug.c
debug.c:41:21: warning: format string is not a string literal [-Wformat-nonliteral]
vfprintf(stdout, fmt, ap);
^~~1 warning generated.
clang -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmpathcmd -DUSE_SYSTEMD=229 -DLIBDM_API_FLUSH -D_GNU_SOURCE -DLIBDM_API_COOKIE -DLIBUDEV_API_RECVBUF -DLIBDM_API_DEFERRED -c -o log_pthread.o log_pthread.c log_pthread.c:28:17: warning: format string is not a string literal [-Wformat-nonliteral]
vsyslog(prio, fmt, ap);
^~~1 warning generated.
clang -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmpathcmd -DUSE_SYSTEMD=229 -DLIBDM_API_FLUSH -D_GNU_SOURCE -DLIBDM_API_COOKIE -DLIBUDEV_API_RECVBUF -DLIBDM_API_DEFERRED -c -o log.o log.c
log.c:121:32: warning: format string is not a string literal [-Wformat-nonliteral]
vsnprintf(buff, MAX_MSG_SIZE, fmt, ap);
^~~1 warning generated.
Quoted 1 line · Xose Vazquez Perez
With this patch, clang is emitting four new warnings:
Hello Xose,
-Wformat-nonliteral helped me to catch a real bug. How about suppressing these warnings with a #pragma statement (see also http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas)?
Bart.
Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Xose Vazquez Perez
With this patch, clang is emitting four new warnings:
-Wformat-nonliteral helped me to catch a real bug. How about suppressing these warnings with a #pragma statement (see also
http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas)?
I don't know if it's worth pollutes the code to save a pair of clang warnings.