From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97217 invoked by alias); 4 Apr 2017 18:44:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 97139 invoked by uid 89); 4 Apr 2017 18:44:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Apr 2017 18:44:15 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 6B5C110A82D; Tue, 4 Apr 2017 14:44:15 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Cc: Pedro Alves Subject: Re: [PATCH 06/18] -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info Date: Tue, 04 Apr 2017 18:44:00 -0000 Message-ID: <5053106.B2ozUkbjIn@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-STABLE; KDE/4.14.10; amd64; ; ) In-Reply-To: <1491326751-16180-7-git-send-email-palves@redhat.com> References: <1491326751-16180-1-git-send-email-palves@redhat.com> <1491326751-16180-7-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00057.txt.bz2 On Tuesday, April 04, 2017 06:25:39 PM Pedro Alves wrote: > -Wwrite-strings flagged a missing cast for example here: > > static char * > ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp) > { > return "Ravenscar task"; > > Since callers are not supposed to free the string returned by these > methods, change the methods' signature to return const strings. > > gdb/ChangeLog: > yyyy-mm-dd Pedro Alves > > diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c > index 9f4f9e7..98e2428 100644 > --- a/gdb/bsd-kvm.c > +++ b/gdb/bsd-kvm.c > @@ -329,7 +329,7 @@ bsd_kvm_thread_alive (struct target_ops *ops, > return 1; > } > > -static char * > +static const char * > bsd_kvm_pid_to_str (struct target_ops *ops, ptid_t ptid) > { > static char buf[64]; > diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c > index 08b8f36..5d4775c 100644 > --- a/gdb/bsd-uthread.c > +++ b/gdb/bsd-uthread.c > @@ -491,7 +491,7 @@ static char *bsd_uthread_state[] = > /* Return a string describing th state of the thread specified by > INFO. */ > > -static char * > +static const char * > bsd_uthread_extra_thread_info (struct target_ops *self, > struct thread_info *info) > { > @@ -511,7 +511,7 @@ bsd_uthread_extra_thread_info (struct target_ops *self, > return NULL; > } > > -static char * > +static const char * > bsd_uthread_pid_to_str (struct target_ops *ops, ptid_t ptid) > { > if (ptid_get_tid (ptid) != 0) > diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c > index d99f436..96781cd 100644 > --- a/gdb/fbsd-nat.c > +++ b/gdb/fbsd-nat.c > @@ -368,7 +368,7 @@ fbsd_thread_alive (struct target_ops *ops, ptid_t ptid) > /* Convert PTID to a string. Returns the string in a static > buffer. */ > > -static char * > +static const char * > fbsd_pid_to_str (struct target_ops *ops, ptid_t ptid) > { > lwpid_t lwp; > diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c > index 46875d8..b834ce3 100644 > --- a/gdb/fbsd-tdep.c > +++ b/gdb/fbsd-tdep.c > @@ -32,7 +32,7 @@ > > /* This is how we want PTIDs from core files to be printed. */ > > -static char * > +static const char * > fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) > { > static char buf[80]; These look fine to me (as well as the change in general). -- John Baldwin