This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/4] S390: For zero, let is_power_of_two() return false
- From: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: Sergio Durigan Junior <sergiodj at redhat dot com>, Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Wed, 22 Apr 2015 19:49:11 +0200
- Subject: [PATCH 1/4] S390: For zero, let is_power_of_two() return false
- Authentication-results: sourceware.org; auth=none
- References: <1429724743-4603-1-git-send-email-arnez at linux dot vnet dot ibm dot com>
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/s390-linux-tdep.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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,
--
1.9.3