From 7a1149643d8621541025e2c70e6391e901c8c7ef Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 5 Apr 2017 19:21:34 +0100 Subject: -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info -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: 2017-04-05 Pedro Alves * aix-thread.c (aix_thread_pid_to_str) (aix_thread_extra_thread_info): Constify. * bsd-kvm.c (bsd_kvm_pid_to_str): Constify. * bsd-uthread.c (bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Constify. * corelow.c (core_pid_to_str): Constify. * darwin-nat.c (darwin_pid_to_str): Constify. * fbsd-nat.c (fbsd_pid_to_str): Constify. * fbsd-tdep.c (fbsd_core_pid_to_str, gdbarch_core_pid_to_str): Constify. * gnu-nat.c (gnu_pid_to_str): Constify. * go32-nat.c (go32_pid_to_str): Constify. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Constify. * inf-ptrace.c (inf_ptrace_pid_to_str): Constify. * inferior.c (inferior_pid_to_str): Constify. * linux-nat.c (linux_nat_pid_to_str): Constify. * linux-tdep.c (linux_core_pid_to_str): Constify. * linux-thread-db.c (thread_db_pid_to_str) (thread_db_extra_thread_info): Constify. * nto-tdep.c (nto_extra_thread_info): Constify. * nto-tdep.h (nto_extra_thread_info): Constify. * obsd-nat.c (obsd_pid_to_str): Constify. * procfs.c (procfs_pid_to_str): Constify. * ravenscar-thread.c (ravenscar_extra_thread_info) (ravenscar_pid_to_str): Constify. * remote-sim.c (gdbsim_pid_to_str): Constify. * remote.c (remote_threads_extra_info, remote_pid_to_str): Constify. * sol-thread.c (solaris_pid_to_str): Constify. * sol2-tdep.c (sol2_core_pid_to_str): Constify. * sol2-tdep.h (sol2_core_pid_to_str): Constify. * target.c (default_pid_to_str, target_pid_to_str) (normal_pid_to_str, default_pid_to_str): Constify. * target.h (target_ops::to_pid_to_str) (target_ops::to_extra_thread_info): Constify. (target_pid_to_str, normal_pid_to_str): Constify. * windows-nat.c (windows_pid_to_str): Constify. * gdbarch.sh (core_pid_to_str): Constify. * target-delegates.c: Regenerate. * gdbarch.h, gdbarch.c: Regenerate. --- gdb/target-delegates.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gdb/target-delegates.c') diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 470b7e4..88e3e0b 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -1502,17 +1502,17 @@ debug_update_thread_list (struct target_ops *self) fputs_unfiltered (")\n", gdb_stdlog); } -static char * +static const char * delegate_pid_to_str (struct target_ops *self, ptid_t arg1) { self = self->beneath; return self->to_pid_to_str (self, arg1); } -static char * +static const char * debug_pid_to_str (struct target_ops *self, ptid_t arg1) { - char * result; + const char * result; fprintf_unfiltered (gdb_stdlog, "-> %s->to_pid_to_str (...)\n", debug_target.to_shortname); result = debug_target.to_pid_to_str (&debug_target, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->to_pid_to_str (", debug_target.to_shortname); @@ -1520,28 +1520,28 @@ debug_pid_to_str (struct target_ops *self, ptid_t arg1) fputs_unfiltered (", ", gdb_stdlog); target_debug_print_ptid_t (arg1); fputs_unfiltered (") = ", gdb_stdlog); - target_debug_print_char_p (result); + target_debug_print_const_char_p (result); fputs_unfiltered ("\n", gdb_stdlog); return result; } -static char * +static const char * delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1) { self = self->beneath; return self->to_extra_thread_info (self, arg1); } -static char * +static const char * tdefault_extra_thread_info (struct target_ops *self, struct thread_info *arg1) { return NULL; } -static char * +static const char * debug_extra_thread_info (struct target_ops *self, struct thread_info *arg1) { - char * result; + const char * result; fprintf_unfiltered (gdb_stdlog, "-> %s->to_extra_thread_info (...)\n", debug_target.to_shortname); result = debug_target.to_extra_thread_info (&debug_target, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->to_extra_thread_info (", debug_target.to_shortname); @@ -1549,7 +1549,7 @@ debug_extra_thread_info (struct target_ops *self, struct thread_info *arg1) fputs_unfiltered (", ", gdb_stdlog); target_debug_print_struct_thread_info_p (arg1); fputs_unfiltered (") = ", gdb_stdlog); - target_debug_print_char_p (result); + target_debug_print_const_char_p (result); fputs_unfiltered ("\n", gdb_stdlog); return result; } -- cgit v1.1