Skip to contentSkip to conversation

support/nfs/xcommon.c: fix a formatting error with clang

PATCH In review Alexander Kanavin 2 participants 2 messages Mar 21, 2025 – Mar 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/nfs/xcommon.c: fix a formatting error with clang

Specifically, this happens:

| xcommon.c:101:24: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
|   101 |      vfprintf (stderr, fmt2, args);
|       |                        ^~~~

A similar approach (print \n seprately) is already used elsewhere in the same file.

---
 support/nfs/xcommon.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
support/nfs/xcommon.c +2 -4
index 3989f0bc..1d04dd11 100644
@@ -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.39.5
#1 lore raw
Quoted 10 lines · Alexander Kanavin

Specifically, this happens:

| xcommon.c:101:24: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
|   101 |      vfprintf (stderr, fmt2, args);
|       |                        ^~~~

A similar approach (print \n seprately) is already used elsewhere in the same file.

Committed... (tag: nfs-utils-2-8-3-rc8)

steved.

Quoted 24 lines
---
  support/nfs/xcommon.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
support/nfs/xcommon.c +2 -4
index 3989f0bc..1d04dd11 100644
@@ -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.