This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gdb/i387-tdep.c: Avoid warning for "-Werror=strict-overflow"
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: gang dot chen dot 5i5j at gmail dot com
- Cc: amodra at gmail dot com, gbenson at redhat dot com, michael dot sturm at intel dot com, brobecker at adacore dot com, walfred dot tedeschi at intel dot com, binutils at sourceware dot org, gdb-patches at sourceware dot org
- Date: Fri, 3 Oct 2014 17:46:49 +0200 (CEST)
- Subject: Re: [PATCH] gdb/i387-tdep.c: Avoid warning for "-Werror=strict-overflow"
- Authentication-results: sourceware.org; auth=none
- References: <542EC11C dot 3020406 at gmail dot com>
>
> 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.
> 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)
>