qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH] tcg: Fix compiler error (comparison of unsigned


From: Hollis Blanchard
Subject: [Qemu-devel] Re: [PATCH] tcg: Fix compiler error (comparison of unsigned expression)
Date: Fri, 8 Oct 2010 09:57:51 -0700

On Fri, Oct 8, 2010 at 1:32 AM, Stefan Weil <address@hidden> wrote:
> When qemu is configured with --enable-debug-tcg,
> gcc throws this warning (or error with -Werror):
>
> tcg/tcg.c:1030: error: comparison of unsigned expression >= 0 is always true
>
> Fix it by removing the >= 0 part.
> The type cast to 'unsigned' catches negative values of op
> (which should never happen).
>
> This is a modification of Hollis Blanchard's patch.
>
> Cc: Hollis Blanchard <address@hidden>
> Cc: Blue Swirl <address@hidden>
> Signed-off-by: Stefan Weil <address@hidden>
> ---
>  tcg/tcg.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index e0a9030..0cdef0d 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -1027,7 +1027,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef 
> *tdefs)
>         if (tdefs->op == (TCGOpcode)-1)
>             break;
>         op = tdefs->op;
> -        assert(op >= 0 && op < NB_OPS);
> +        assert((unsigned)op < NB_OPS);
>         def = &tcg_op_defs[op];
>  #if defined(CONFIG_DEBUG_TCG)
>         /* Duplicate entry in op definitions? */

According to the warning, op is already unsigned, so this simply
removes the >=0 test, which was my original patch.

In contrast, Blue wanted a cast to int, as seen in
95ee3914bfd551aeec49932a400530141865acad.

-Hollis



reply via email to

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