This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 06/18] -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info


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  <palves@redhat.com>
> 
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]