]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
fmt: eliminate a clang -Wformat-extra-args warning
authorBruno Haible <bruno@clisp.org>
Thu, 18 Sep 2025 21:05:06 +0000 (23:05 +0200)
committerPádraig Brady <P@draigBrady.com>
Thu, 18 Sep 2025 21:33:51 +0000 (22:33 +0100)
* src/fmt.c (fmt): When not reading from stdin, always mention the
file name in the error message.

src/fmt.c

index b44bbde5c7cf2c76de529f395248ab22c55c75eb..244a8a5c926c1f77d2d800d4bf96f906eb482300 100644 (file)
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -493,12 +493,18 @@ fmt (FILE *f, char const *file)
     }
 
   int err = ferror (f) ? 0 : -1;
+  /* err < 0 means success.  */
   if (f == stdin)
     clearerr (f);
   else if (fclose (f) != 0 && err < 0)
     err = errno;
   if (0 <= err)
-    error (0, err, err ? "%s" : _("read error"), quotef (file));
+    {
+      if (f == stdin)
+        error (0, err, _("read error"));
+      else
+        error (0, err, _("error reading %s"), quoteaf (file));
+    }
   return err < 0;
 }