From patchwork Tue Apr 19 21:40:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 11808 Received: (qmail 127431 invoked by alias); 19 Apr 2016 21:41:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 127317 invoked by uid 89); 19 Apr 2016 21:41:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy= X-HELO: bigwig.baldwin.cx Received: from bigwig.baldwin.cx (HELO bigwig.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 19 Apr 2016 21:41:14 +0000 Received: from ralph.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id F3079B99B for ; Tue, 19 Apr 2016 17:41:11 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Cast the pointer assigned to ss_sp to char *. Date: Tue, 19 Apr 2016 14:40:02 -0700 Message-Id: <8e120e99ac187140f4b9f4ad2a4e3613fe765095.1461101705.git.jhb@FreeBSD.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes 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 + + * main.c (setup_alternate_signal_stack): Cast to char *. + 2016-04-19 Doug Evans * 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;