This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Cast the pointer assigned to ss_sp to char *.
- From: John Baldwin <jhb at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 19 Apr 2016 23:11:22 -0000
- Subject: [binutils-gdb] Cast the pointer assigned to ss_sp to char *.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f39c07acc8c4039534a9c6f1757de82afe66ecd5
commit f39c07acc8c4039534a9c6f1757de82afe66ecd5
Author: John Baldwin <jhb@FreeBSD.org>
Date: Tue Apr 19 13:51:05 2016 -0700
Cast the pointer assigned to ss_sp to char *.
FreeBSD versions older than 11.0 use char * as the type of ss_sp in
stack_t instead of the standards-defined void *. C++ allows a char *
pointer to be converted to a void *, so it is safe to cast the return
value of xmalloc to char * if ss_sp is either a char * or void *.
Just always use the cast to char * since that is less ugly than having
to add a special case.
gdb/ChangeLog:
* main.c (setup_alternate_signal_stack): Cast to char *.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/main.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ca7c9de..05052c9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2016-04-19 John Baldwin <jhb@FreeBSD.org>
+
+ * main.c (setup_alternate_signal_stack): Cast to char *.
+
2016-04-19 Doug Evans <xdje42@gmail.com>
* symmisc.c (dump_symtab_1, dump_symtab): Delete arg objfile.
diff --git a/gdb/main.c b/gdb/main.c
index c149b70..2ce1713 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -297,7 +297,9 @@ setup_alternate_signal_stack (void)
#ifdef HAVE_SIGALTSTACK
stack_t ss;
- ss.ss_sp = xmalloc (SIGSTKSZ);
+ /* FreeBSD versions older than 11.0 use char * for ss_sp instead of
+ void *. This cast works with both types. */
+ ss.ss_sp = (char *) xmalloc (SIGSTKSZ);
ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;