From b25146b67c3c2a1e63fdb8882ee56ade39ef5f49 Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Fri, 11 Oct 2024 12:17:19 +0800 Subject: [PATCH] btrfs-progs: fix usage warning in common/help.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On systems with glibc 2.34 and 2.39, the following warning appears when building the binary, causing concern that something has failed. [CC] common/help.o common/help.c: In function ‘usage’: common/help.c:315:58: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 315 | fprintf(outf, "No short description for '%s'\n", token); | ^~ common/help.c:312:46: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 312 | fprintf(outf, "No usage for '%s'\n", token); | ^~ The compiler warns that in some code paths, the token is `NULL`. Silence the warning by checking if the token is `NULL`. Reviewed-by: Qu Wenruo Signed-off-by: Anand Jain --- common/help.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/help.c b/common/help.c index 6cf8e2a9b2..0ee00a3a13 100644 --- a/common/help.c +++ b/common/help.c @@ -309,10 +309,10 @@ static int usage_command_internal(const char * const *usagestr, ret = do_usage_one_command(usagestr, flags, cmd_flags, outf); switch (ret) { case -1: - fprintf(outf, "No usage for '%s'\n", token); + fprintf(outf, "No usage for '%s'\n", token ? : ""); break; case -2: - fprintf(outf, "No short description for '%s'\n", token); + fprintf(outf, "No short description for '%s'\n", token ? : ""); break; }