[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/5] qtest: Avoid passing raw strings through hm
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 4/5] qtest: Avoid passing raw strings through hmp() |
Date: |
Thu, 20 Jul 2017 12:03:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Eric Blake <address@hidden> writes:
> 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.
More importantly (for me), "%s" makes correctness locally obvious.
Before the patch, I have to prove the argument can't contain '%'.
> Signed-off-by: Eric Blake <address@hidden>
> ---
> 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 d77b3c8..0af0664 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');
Reviewed-by: Markus Armbruster <address@hidden>
- [Qemu-devel] [PATCH 0/5] random qapi cleanups, Eric Blake, 2017/07/14
- [Qemu-devel] [PATCH 1/5] qapi: Further enhance visitor virtual walk doc example, Eric Blake, 2017/07/14
- [Qemu-devel] [PATCH 2/5] tests: Enhance qobject output to cover partial visit, Eric Blake, 2017/07/14
- [Qemu-devel] [PATCH 3/5] qapi: Visitor documentation tweak, Eric Blake, 2017/07/14
- [Qemu-devel] [PATCH 5/5] qtest: Document calling conventions, Eric Blake, 2017/07/14
- [Qemu-devel] [PATCH 4/5] qtest: Avoid passing raw strings through hmp(), Eric Blake, 2017/07/14
- Re: [Qemu-devel] [PATCH 4/5] qtest: Avoid passing raw strings through hmp(),
Markus Armbruster <=
- Re: [Qemu-devel] [PATCH 0/5] random qapi cleanups, Markus Armbruster, 2017/07/18