This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=35f1fea3fcd44546a6cf074029c284c64ad25b3c

commit 35f1fea3fcd44546a6cf074029c284c64ad25b3c
Author: Maciej W. Rozycki <macro@mips.com>
Date:   Tue May 22 22:52:14 2018 +0100

    gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'
    
    Make `i' defined within `i387_collect_xsave' unsigned, removing a
    `-Werror=strict-overflow' compilation error:
    
    .../gdb/i387-tdep.c: In function 'void i387_collect_xsave(const regcache*, int, void*, int)':
    .../gdb/i387-tdep.c:1348:1: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
     i387_collect_xsave (const struct regcache *regcache, int regnum,
     ^
    cc1plus: all warnings being treated as errors
    Makefile:1610: recipe for target 'i387-tdep.o' failed
    make: *** [i387-tdep.o] Error 1
    
    seen with GCC 5.4.0, a commit 8ee22052f690 ("gdb/x86: Handle kernels
    using compact xsave format") regression.  While `regnum' can be -1 on
    entry to the function, to mean all registers, `i' is only used with
    non-negative register numbers.
    
    	gdb/
    	* i387-tdep.c (i387_collect_xsave): Make `i' unsigned.

Diff:
---
 gdb/ChangeLog   | 4 ++++
 gdb/i387-tdep.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b17512b..d5cd413 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2018-05-22  Maciej W. Rozycki  <macro@mips.com>
+
+	* i387-tdep.c (i387_collect_xsave): Make `i' unsigned.
+
 2018-05-22  Pedro Alves  <palves@redhat.com>
 
 	* remote-fileio.c (remote_fileio_reply, remote_fileio_ioerror)
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 3effc35..fdd83f1 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -1354,7 +1354,7 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
   gdb_byte *p, *regs = (gdb_byte *) xsave;
   gdb_byte raw[I386_MAX_REGISTER_SIZE];
   ULONGEST initial_xstate_bv, clear_bv, xstate_bv = 0;
-  int i;
+  unsigned int i;
   enum
     {
       x87_ctrl_or_mxcsr = 0x1,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]