[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/4] qapi/error: Check format string argument in error_*prepend()
From: |
Markus Armbruster |
Subject: |
[PULL 4/4] qapi/error: Check format string argument in error_*prepend() |
Date: |
Fri, 24 Jul 2020 15:47:04 +0200 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
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 by addint the format
attribute to error_propagate_prepend() and error_vprepend().
This would have caught the bug fixed in the previous commit.
Missed in commit 4b5766488f "error: Fix use of error_prepend() with
&error_fatal, &error_abort".
Inspired-by: Stefan Weil <sw@weilnetz.de>
Suggested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200723171205.14949-1-philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
include/qapi/error.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/qapi/error.h b/include/qapi/error.h
index 7932594dce..eaa05c4837 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -382,13 +382,15 @@ void error_propagate(Error **dst_errp, Error *local_err);
* Please use ERRP_GUARD() and error_prepend() instead when possible.
*/
void error_propagate_prepend(Error **dst_errp, Error *local_err,
- const char *fmt, ...);
+ const char *fmt, ...)
+ GCC_FMT_ATTR(3, 4);
/*
* Prepend some text to @errp's human-readable error message.
* The text is made by formatting @fmt, @ap like vprintf().
*/
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
+void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
+ GCC_FMT_ATTR(2, 0);
/*
* Prepend some text to @errp's human-readable error message.
--
2.26.2
- [PULL 0/4] Error reporting patches patches for 2020-07-24, Markus Armbruster, 2020/07/24
- [PULL 1/4] coccinelle/err-bad-newline: Fix for Python 3, and add patterns, Markus Armbruster, 2020/07/24
- [PULL 4/4] qapi/error: Check format string argument in error_*prepend(),
Markus Armbruster <=
- [PULL 3/4] sd/milkymist-memcard: Fix format string, Markus Armbruster, 2020/07/24
- [PULL 2/4] error: Strip trailing '\n' from error string arguments (again), Markus Armbruster, 2020/07/24
- Re: [PULL 0/4] Error reporting patches patches for 2020-07-24, Peter Maydell, 2020/07/25