Re: [PATCH] gdb/i387-tdep.c: Avoid warning for "-Werror=strict-overflow"

Chen Gang
2014-10-03T16:02:46Z

On 10/3/14 23:46, Mark Kettenis wrote:
>>
>> gdb requires "-Werror", and I387_ST0_REGNUM (tdep) is 'variable', then
>> compiler can think that I387_ST0_REGNUM (tdep) may be a large number,
>> which may cause issue, so report warning.
>
> Sorry, but obfuscating code to make compilers happy is *not* the way to go.
>

OK, I can understand, but for me, these is no other better ways for it,
except let gdb give up "-Werror" (if always need "--disable-werror"
during "configure").

Thanks.

>> 2014-10-03 Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> *i387-tdep.c (i387_supply_fsave): Avoid warning for
>> "-Werror=strict-overflow"
>> ---
>> gdb/i387-tdep.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
>> index d66ac6a..c89e647 100644
>> --- a/gdb/i387-tdep.c
>> +++ b/gdb/i387-tdep.c
>> @@ -454,7 +454,7 @@ i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
>>
>> gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
>>
>> - for (i = I387_ST0_REGNUM (tdep); i < I387_XMM0_REGNUM (tdep); i++)
>> + for (i = I387_ST0_REGNUM (tdep); I387_XMM0_REGNUM (tdep) - i > 0; i++)
>> if (regnum == -1 || regnum == i)
>> {
>> if (fsave == NULL)
>> @@ -507,7 +507,7 @@ i387_collect_fsave (const struct regcache *regcache, int regnum, void *fsave)
>>
>> gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
>>
>> - for (i = I387_ST0_REGNUM (tdep); i < I387_XMM0_REGNUM (tdep); i++)
>> + for (i = I387_ST0_REGNUM (tdep); I387_XMM0_REGNUM (tdep) - i > 0; i++)
>> if (regnum == -1 || regnum == i)
>> {
>> /* Most of the FPU control registers occupy only 16 bits in
>> --
>> 1.8.5.2 (Apple Git-48)
>>

--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed