qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] coverity: provide Coverity-friendly MIN_CONST and MAX_CONST


From: Peter Maydell
Subject: Re: [PATCH] coverity: provide Coverity-friendly MIN_CONST and MAX_CONST
Date: Mon, 29 Jun 2020 16:38:43 +0100

On Mon, 29 Jun 2020 at 16:34, Eric Blake <eblake@redhat.com> wrote:
>
> On 6/29/20 10:16 AM, Paolo Bonzini wrote:
> > Coverity's parser chokes on __builtin_choose_expr inside a constant
> > expression.  Since it is used only to raise compilation errors for
> > non-constant arguments, we can just assume there are no such errors
> > in the Coverity runs, and define MIN_CONST and MAX_CONST to the
> > "classic" ternary-operator-based definitions of minimum and maximum.
> >
> > Reported-by: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> >   include/qemu/osdep.h | 17 ++++++++++++-----
> >   1 file changed, 12 insertions(+), 5 deletions(-)
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
> I wrote a variant in the meantime, and in comparing the two, the only
> major difference was that I added a line:
>
>      Fixes: CID 1429992, CID 1429995, CID 1429997, CID 1429999
>
> in the commit message, as well as a comment in osdep.h:
>
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 0d26a1b9bd07..98bc7156fa9b 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -250,7 +250,8 @@ extern int daemon(int, int);
>    * Note that neither form is usable as an #if condition; if you truly
>    * need to write conditional code that depends on a minimum or maximum
>    * determined by the pre-processor instead of the compiler, you'll
> - * have to open-code it.
> + * have to open-code it.  Sadly, Coverity is severely confused by the
> + * constant variants, so we have to dumb things down there.
>    */
>   #undef MIN
>   #define MIN(a, b)                                       \
>
>
> I'm fine whether or not we include that.

I would vote for including the comment improvement, please.

-- PMM



reply via email to

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