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] S390: For zero, let is_power_of_two() return false


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

commit 6dbc9c045741c27435b9b23246c2113221b26c2f
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date:   Mon Apr 27 11:38:46 2015 +0200

    S390: For zero, let is_power_of_two() return false
    
    This fixes a minor issue with the helper function is_power_of_two(),
    which returned non-zero ("true") if the argument was zero.  This led
    to a wrong decision when passing a zero-sized struct in an inferior
    function call.
    
    gdb/ChangeLog:
    
    	* s390-linux-tdep.c (is_power_of_two): Add comment.  Return
    	  false if the argument is zero.

Diff:
---
 gdb/ChangeLog         | 5 +++++
 gdb/s390-linux-tdep.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d180e38..f922735 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-27  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+	* s390-linux-tdep.c (is_power_of_two): Add comment.  Return
+	  false if the argument is zero.
+
 2015-04-27  Pierre-Marie de Rodat  <derodat@adacore.com>
 
 	* ada-lang.c (template_to_static_fixed_type): Return input type
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index b83a264..44feee7 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -2484,11 +2484,12 @@ is_float_like (struct type *type)
 	  || is_float_singleton (type));
 }
 
+/* Determine whether N is a power of two.  */
 
 static int
 is_power_of_two (unsigned int n)
 {
-  return ((n & (n - 1)) == 0);
+  return n && ((n & (n - 1)) == 0);
 }
 
 /* Return non-zero if TYPE should be passed as a pointer to a copy,


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