qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [Qemu-devel] [PATCH v2 3/4] qtest: Avoid passing raw strings through hmp()
Date: Thu, 20 Jul 2017 16:40:07 -0500	[thread overview]
Message-ID: <20170720214008.28494-4-eblake@redhat.com> (raw)
In-Reply-To: <20170720214008.28494-1-eblake@redhat.com>

The next patch will add __attribute__((__format__)) to hmp(), which
in turn causes gcc to warn about non-literal format strings.  Rather
than risk an arbitrary string containing % being mis-handled, always
pass variable strings along with a %s format.  It also makes it
easier to prove correctness locally, rather than auditing all the
source strings.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 tests/test-hmp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test-hmp.c b/tests/test-hmp.c
index d77b3c8710..0af066487c 100644
--- a/tests/test-hmp.c
+++ b/tests/test-hmp.c
@@ -80,7 +80,7 @@ static void test_commands(void)
         if (verbose) {
             fprintf(stderr, "\t%s\n", hmp_cmds[i]);
         }
-        response = hmp(hmp_cmds[i]);
+        response = hmp("%s", hmp_cmds[i]);
         g_free(response);
     }

@@ -103,7 +103,7 @@ static void test_info_commands(void)
         if (verbose) {
             fprintf(stderr, "\t%s\n", info);
         }
-        resp = hmp(info);
+        resp = hmp("%s", info);
         g_free(resp);
         /* And move forward to the next line */
         info = strchr(endp + 1, '\n');
-- 
2.13.3

  parent reply	other threads:[~2017-07-20 21:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20 21:40 [Qemu-devel] [PATCH for-2.10? v2 0/4] random qapi cleanups Eric Blake
2017-07-20 21:40 ` [Qemu-devel] [PATCH v2 1/4] tests: Enhance qobject output to cover partial visit Eric Blake
2017-07-20 21:40 ` [Qemu-devel] [PATCH v2 2/4] qapi: Visitor documentation tweak Eric Blake
2017-07-20 21:40 ` Eric Blake [this message]
2017-07-21 13:50   ` [Qemu-devel] [PATCH v2 3/4] qtest: Avoid passing raw strings through hmp() Markus Armbruster
2017-07-21 14:04     ` Eric Blake
2017-07-21 14:32       ` Markus Armbruster
2017-07-20 21:40 ` [Qemu-devel] [PATCH v2 4/4] qtest: Document calling conventions Eric Blake
2017-07-20 22:08 ` [Qemu-devel] [PATCH for-2.10? v2 0/4] random qapi cleanups no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170720214008.28494-4-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).