Skip to content

Commit 192cf54

Browse files
philmdMarkus Armbruster
authored andcommitted
qapi/error: Check format string argument in error_*prepend()
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 4b57664 "error: Fix use of error_prepend() with &error_fatal, &error_abort". Inspired-by: Stefan Weil <[email protected]> Suggested-by: Eric Blake <[email protected]> Reviewed-by: Stefan Weil <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> [Commit message tweaked] Signed-off-by: Markus Armbruster <[email protected]>
1 parent 8388863 commit 192cf54

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/qapi/error.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,15 @@ void error_propagate(Error **dst_errp, Error *local_err);
382382
* Please use ERRP_GUARD() and error_prepend() instead when possible.
383383
*/
384384
void error_propagate_prepend(Error **dst_errp, Error *local_err,
385-
const char *fmt, ...);
385+
const char *fmt, ...)
386+
GCC_FMT_ATTR(3, 4);
386387

387388
/*
388389
* Prepend some text to @errp's human-readable error message.
389390
* The text is made by formatting @fmt, @ap like vprintf().
390391
*/
391-
void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
392+
void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
393+
GCC_FMT_ATTR(2, 0);
392394

393395
/*
394396
* Prepend some text to @errp's human-readable error message.

0 commit comments

Comments
 (0)