qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH-for-5.1?] qapi/error: Check format string argument in error_p


From: Markus Armbruster
Subject: Re: [PATCH-for-5.1?] qapi/error: Check format string argument in error_propagate_prepend()
Date: Thu, 23 Jul 2020 15:09:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> 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

s/catched/caught/

> 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 *

Suggest to shorten to

  This would have caught the bug fixed in the previous commit.

and make sure Stefan's fix actually becomes the previous commit.

> Fixes: 4b5766488f ("Fix use of error_prepend() with &error_fatal, 
> &error_abort")

Kind of.  Omitting the attritbute isn't wrong, just foolish / careless.

I'd write

  Missed in commit 4b5766488f "error: 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>

If you like my tweaks, I can apply them in my tree.

> ---
>  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, ...);

Reviewed-by: Markus Armbruster <armbru@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]