Skip to contentSkip to conversation

Fix warning: format not a string literal and no format arguments

PATCH In review Gilles Espinasse 4 participants 4 messages Feb 16, 2011 – Feb 17, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix warning: format not a string literal and no format arguments

Seen with gcc-4.4.5 and -Wformat -Wformat-security

---
 options.c |    6 +++---
 push.c    |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
options.c +3 -3
index 5f1efc5..208db30 100644
@@ -4002,7 +4002,7 @@ add_option (struct options *options,
 		    {
 		      if (options->inetd != -1)
 			{
-			  msg (msglevel, opterr);
+			  msg (msglevel, "%s", opterr);
 			  goto err;
 			}
 		      else
@@ -4012,7 +4012,7 @@ add_option (struct options *options,
 		    {
 		      if (options->inetd != -1)
 			{
-			  msg (msglevel, opterr);
+			  msg (msglevel, "%s", opterr);
 			  goto err;
 			}
 		      else
@@ -4022,7 +4022,7 @@ add_option (struct options *options,
 		    {
 		      if (name != NULL)
 			{
-			  msg (msglevel, opterr);
+			  msg (msglevel, "%s", opterr);
 			  goto err;
 			}
 		      name = p[z];
push.c +2 -2
index 9ddc900..86ac4a7 100644
@@ -178,7 +178,7 @@ send_push_reply (struct context *c)
   const int extra = 64; /* extra space for possible trailing ifconfig and push-continuation */
   const int safe_cap = BCAP (&buf) - extra;
 
-  buf_printf (&buf, cmd);
+  buf_printf (&buf, "%s", cmd);
 
   while (e)
     {
@@ -194,7 +194,7 @@ send_push_reply (struct context *c)
 		  goto fail;
 		multi_push = true;
 		buf_reset_len (&buf);
-		buf_printf (&buf, cmd);
+		buf_printf (&buf, "%s", cmd);
 	      }
 	    }
 	  if (BLEN (&buf) + l >= safe_cap)
Signature · 1 line
1.7.3.4
#2 lore raw
In reply to Gilles Espinasse

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 16/02/11 22:55, Gilles Espinasse wrote:

| Seen with gcc-4.4.5 and -Wformat -Wformat-security
|
| Signed-off-by: Gilles Espinasse<[email protected]...>
| ---
|   options.c |    6 +++---
|   push.c    |    4 ++--
|   2 files changed, 5 insertions(+), 5 deletions(-)

Thank you very much, but I'm sorry to be a party killer ... this is already implemented in the beta2.2, bugfix2.1 and allmerged branches.

commit d6b783a8ec505c8e158bd0304c5e195cff5bb8c3

Author: David Sommerseth <[email protected]...>
Date:   Fri Sep 17 17:10:25 2010 +0200

~ Fixed compiler warnings reported on Ubuntu 10.04

~    The warnings reported where:
~    --------------------------------------------------------
~    misc.c:158: warning: ignoring return value of ?nice?, declared with
~    attribute warn_unused_result
~    options.c:4033: warning: format not a string literal and no format
~    arguments
~    options.c:4043: warning: format not a string literal and no format
~    arguments
~    options.c:4053: warning: format not a string literal and no format
~    arguments
~    push.c:182: warning: format not a string literal and no format arguments
~    push.c:199: warning: format not a string literal and no format arguments
~    push.c:235: warning: format not a string literal and no format arguments
~    status.c:171: warning: ignoring return value of ?ftruncate?, declared
~    with attribute warn_unused_result
~    --------------------------------------------------------
~    Signed-off-by: David Sommerseth <[email protected]...>
~    Acked-by: Gert Doering <[email protected]...>
~    Acked-by: Peter Stuge <[email protected]...>

But good catch! Please be sure you check against at least the allmerged branch in the future, and you might avoid dumping into this issue again.

And kudos for using the git tree and git send-email!

We're also in the last stages of finalising the 2.2-RC release, so in the near future beta2.2 will become our master branch. The git tree will go through some minor changes, and we will simplify where to grab the correct code.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk1cZc4ACgkQDC186MBRfrocIwCfUqNQIH/0D+OGZrNoW4QeauDg AqIAoJ29S4PtV3NCiPQxnq4GldOS+sAK
=SNZs
-----END PGP SIGNATURE-----