S390: For zero, let is_power_of_two() return false
authorAndreas Arnez <arnez@linux.vnet.ibm.com>
Mon, 27 Apr 2015 09:38:46 +0000 (11:38 +0200)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Mon, 27 Apr 2015 09:38:46 +0000 (11:38 +0200)
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.

gdb/ChangeLog
gdb/s390-linux-tdep.c

index d180e38b598f07e32906360fc0c9c65553be751d..f922735bb1e16d8f413daaa9dbf7ee82aa3039d1 100644 (file)
@@ -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
index b83a264ee86af6c53c9b133343b6c5c141ac4aed..44feee7bbea8a6fbe304650dcd887da9efdf8343 100644 (file)
@@ -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,
This page took 0.029093 seconds and 4 git commands to generate.