git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] builtin-receive-pack.c: fix compiler warnings about format string

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Feb 15, 2009, 18:18 UTC
Message-ID
<1234721938.17613.21.camel@ubuntu.ubuntu-domain>

While all of the strings passed to warning() are, in fact, literals, the compiler doesn't recognize them as such because it doesn't see through the loop used to iterate over them:

   builtin-receive-pack.c: In function 'warn_unconfigured_deny':
   builtin-receive-pack.c:247: warning: format not a string literal and no format arguments
   builtin-receive-pack.c: In function 'warn_unconfigured_deny_delete_current':
   builtin-receive-pack.c:273: warning: format not a string literal and no format arguments
Calm the compiler by adding easily recognizable format string literals.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 builtin-receive-pack.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index f7e04c4..849f1fe 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -244,7 +244,7 @@ static void warn_unconfigured_deny(void)
 {
 	int i;
 	for (i = 0; i < ARRAY_SIZE(warn_unconfigured_deny_msg); i++)
-		warning(warn_unconfigured_deny_msg[i]);
+		warning("%s", warn_unconfigured_deny_msg[i]);
 }
 
 static char *warn_unconfigured_deny_delete_current_msg[] = {
@@ -270,7 +270,7 @@ static void warn_unconfigured_deny_delete_current(void)
 	for (i = 0;
 	     i < ARRAY_SIZE(warn_unconfigured_deny_delete_current_msg);
 	     i++)
-		warning(warn_unconfigured_deny_delete_current_msg[i]);
+		warning("%s", warn_unconfigured_deny_delete_current_msg[i]);
 }
 
 static const char *update(struct command *cmd)
Next: Junio C Hamano
Message 1 of 2 in “builtin-receive-pack.c: fix compiler warnings about format string”
  1. builtin-receive-pack.c: fix compiler warnings about format stringRené Scharfe, Feb 15, 2009
  2. Junio C HamanoFeb 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.