qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Stefan Weil" <sw@weilnetz.de>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: [PATCH-for-5.1?] qapi/error: Check format string argument in error_propagate_prepend()
Date: Thu, 23 Jul 2020 11:13:09 +0200	[thread overview]
Message-ID: <20200723091309.18690-1-philmd@redhat.com> (raw)

error_propagate_prepend() "behaves like error_prepend()", and
error_prepend() uses "formatting @fmt, ... like printf()".
error_prepend() checks its format string argument, but
error_propagate_prepend() does not. Fix that.

This would have catched the invalid format introduced in commit
b98e8d1230f:

    CC      hw/sd/milkymist-memcard.o
  hw/sd/milkymist-memcard.c: In function ‘milkymist_memcard_realize’:
  hw/sd/milkymist-memcard.c:284:70: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
    284 |         error_propagate_prepend(errp, err, "failed to init SD card: %s");
        |                                                                     ~^
        |                                                                      |
        |                                                                      char *

Fixes: 4b5766488f ("Fix use of error_prepend() with &error_fatal, &error_abort")
Inspired-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/qapi/error.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 7932594dce..eeeef1a34d 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -381,6 +381,7 @@ void error_propagate(Error **dst_errp, Error *local_err);
  *     error_propagate(dst_errp, local_err);
  * Please use ERRP_GUARD() and error_prepend() instead when possible.
  */
+GCC_FMT_ATTR(3, 4)
 void error_propagate_prepend(Error **dst_errp, Error *local_err,
                              const char *fmt, ...);
 
-- 
2.21.3



             reply	other threads:[~2020-07-23  9:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23  9:13 Philippe Mathieu-Daudé [this message]
2020-07-23  9:44 ` [PATCH-for-5.1?] qapi/error: Check format string argument in error_propagate_prepend() Stefan Weil
2020-07-23 10:04   ` Philippe Mathieu-Daudé
2020-07-23 13:16     ` Markus Armbruster
2020-07-23 13:19     ` Eric Blake
2020-07-23 13:09 ` Markus Armbruster

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=20200723091309.18690-1-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /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).