Patchwork fix unsigned comparison warning in TCG

login
register
mail settings
Submitter Hollis Blanchard
Date Sept. 26, 2010, 5:40 p.m.
Message ID <AANLkTikWWTDUqStdFZBOk=ZSv3dv70Ngc9gb-6UuWXuL@mail.gmail.com>
Download mbox | patch
Permalink /patch/65794/
State New
Headers show

Comments

Hollis Blanchard - Sept. 26, 2010, 5:40 p.m.
TCGOpcode is an enum, which apparently can be unsigned.

Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
---

% ./configure --target-list=ppcemb-softmmu --enable-debug
% make
  ...
  CC    ppcemb-softmmu/tcg/tcg.o
cc1: warnings being treated as errors
/home/hollisb/source/qemu.git/tcg/tcg.c: In function
‘tcg_add_target_add_op_defs’:
/home/hollisb/source/qemu.git/tcg/tcg.c:1030: error: comparison of
unsigned expression >= 0 is always true
% gcc -v
gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)
Blue Swirl - Sept. 26, 2010, 6:33 p.m.
On Sun, Sep 26, 2010 at 5:40 PM, Hollis Blanchard <hollis@penguinppc.org> wrote:
> TCGOpcode is an enum, which apparently can be unsigned.
>
> Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
> ---
>
> % ./configure --target-list=ppcemb-softmmu --enable-debug
> % make
>  ...
>  CC    ppcemb-softmmu/tcg/tcg.o
> cc1: warnings being treated as errors
> /home/hollisb/source/qemu.git/tcg/tcg.c: In function
> ‘tcg_add_target_add_op_defs’:
> /home/hollisb/source/qemu.git/tcg/tcg.c:1030: error: comparison of
> unsigned expression >= 0 is always true
> % gcc -v
> gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index e0a9030..7e96859 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -1027,7 +1027,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdef
>         if (tdefs->op == (TCGOpcode)-1)
>             break;
>         op = tdefs->op;
> -        assert(op >= 0 && op < NB_OPS);
> +        assert(op < NB_OPS);

Please add int cast, like 95ee3914bfd551aeec49932a400530141865acad.
jvrao - Oct. 7, 2010, 11:15 p.m.
On 9/26/2010 11:33 AM, Blue Swirl wrote:
> On Sun, Sep 26, 2010 at 5:40 PM, Hollis Blanchard <hollis@penguinppc.org> wrote:
>> TCGOpcode is an enum, which apparently can be unsigned.
>>
>> Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
>> ---
>>
>> % ./configure --target-list=ppcemb-softmmu --enable-debug
>> % make
>>  ...
>>  CC    ppcemb-softmmu/tcg/tcg.o
>> cc1: warnings being treated as errors
>> /home/hollisb/source/qemu.git/tcg/tcg.c: In function
>> ‘tcg_add_target_add_op_defs’:
>> /home/hollisb/source/qemu.git/tcg/tcg.c:1030: error: comparison of
>> unsigned expression >= 0 is always true
>> % gcc -v
>> gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)
>>
>> diff --git a/tcg/tcg.c b/tcg/tcg.c
>> index e0a9030..7e96859 100644
>> --- a/tcg/tcg.c
>> +++ b/tcg/tcg.c
>> @@ -1027,7 +1027,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdef
>>         if (tdefs->op == (TCGOpcode)-1)
>>             break;
>>         op = tdefs->op;
>> -        assert(op >= 0 && op < NB_OPS);
>> +        assert(op < NB_OPS);
> 
> Please add int cast, like 95ee3914bfd551aeec49932a400530141865acad.
> 

What is the latest on this? Waiting for this fix as I use --enable-debug a lot. :)

- JV

Patch

diff --git a/tcg/tcg.c b/tcg/tcg.c
index e0a9030..7e96859 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1027,7 +1027,7 @@  void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdef
         if (tdefs->op == (TCGOpcode)-1)
             break;
         op = tdefs->op;
-        assert(op >= 0 && op < NB_OPS);
+        assert(op < NB_OPS);
         def = &tcg_op_defs[op];
 #if defined(CONFIG_DEBUG_TCG)
         /* Duplicate entry in op definitions? */