public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] Cast the pointer assigned to ss_sp to char *.
Date: Tue, 19 Apr 2016 21:41:00 -0000	[thread overview]
Message-ID: <8e120e99ac187140f4b9f4ad2a4e3613fe765095.1461101705.git.jhb@FreeBSD.org> (raw)
In-Reply-To: <cover.1461101705.git.jhb@FreeBSD.org>
In-Reply-To: <cover.1461101705.git.jhb@FreeBSD.org>

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 *.
---
 gdb/ChangeLog | 4 ++++
 gdb/main.c    | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9e65878..6f681b9 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>
 
 	* source.c (is_regular_file): New arg errno_ptr.
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;
 
-- 
2.7.0

  parent reply	other threads:[~2016-04-19 21:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19 21:41 [PATCH 0/2] Fix C++ build on FreeBSD/x86 John Baldwin
2016-04-19 21:41 ` [PATCH 2/2] Handle void * conversions in FreeBSD/x86 native code to fix C++ build John Baldwin
2016-04-19 22:40   ` Pedro Alves
2016-04-19 21:41 ` John Baldwin [this message]
2016-04-19 22:38   ` [PATCH 1/2] Cast the pointer assigned to ss_sp to char * Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e120e99ac187140f4b9f4ad2a4e3613fe765095.1461101705.git.jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).