From 71a8cdf6b1f04e95aa74a2f304d68530638d229a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 18 Sep 2025 23:05:06 +0200 Subject: [PATCH] fmt: eliminate a clang -Wformat-extra-args warning * src/fmt.c (fmt): When not reading from stdin, always mention the file name in the error message. --- src/fmt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fmt.c b/src/fmt.c index b44bbde5c7..244a8a5c92 100644 --- 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; } -- 2.47.3