Warnings fixes for building with clang
Subsystems (2)
Hi,
Here are a few patches to fix warnings caught while building with clang.
-Tom
PATCH 1/2 Fix -Wformat-nonliteral warning
xcommon.c:101:24: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
vfprintf (stderr, fmt2, args);
^~~~
---
support/nfs/xcommon.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)support/nfs/xcommon.c +2 -4
@@ -94,13 +94,11 @@ xstrconcat4 (const char *s, const char *t, const char *u, const char *v) {void nfs_error (const char *fmt, ...) {va_list args; -char *fmt2; - fmt2 =xstrconcat2 (fmt,"\n" );va_start (args, fmt); -vfprintf (stderr, fmt2, args); +vfprintf (stderr, fmt, args); +fprintf (stderr,"\n" );va_end (args); -free (fmt2); }/* Make a canonical pathname from PATH. Returns a freshly malloced string.
Signature · 1 line
2.25.3
PATCH 2/2 Use format attribute to silence -Wformat-nonliteral warnings
In reply to Tom StellardThis will also cause the compiler to add checks to ensure the arguments are consistent with the printf format.
--- support/nfsidmap/libnfsidmap.c | 2 +- utils/gssd/err_util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
support/nfsidmap/libnfsidmap.c +1 -1
@@ -94,7 +94,7 @@ gid_t nobody_gid = (gid_t)-1;#endif /* Default logging fuction */ -static void default_logger (const char *fmt, ...) +__attribute__ ((format (printf,1 ,2 )))static void default_logger (const char *fmt, ...) {va_list vp;
utils/gssd/err_util.c +1 -1
@@ -50,7 +50,7 @@ void initerr(char *progname, int set_verbosity, int set_fg) } -void printerr (int priority,char *format, ...) +__attribute__ ((format (printf,2 ,3 )))void printerr (int priority,char *format, ...) {va_list args;
Signature · 1 line
2.25.3