From: Andrew Cagney Date: Mon, 28 Jun 2004 23:59:29 +0000 (+0000) Subject: 2004-06-26 Andrew Cagney X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b435e160dd3606c70fee73fa1461cf26607e4d6f;p=binutils-gdb.git 2004-06-26 Andrew Cagney * xcoffsolib.c (xcoff_solib_address): Replace xasprintf with xstrprintf. * varobj.c (varobj_gen_name, create_child, c_name_of_child) (c_value_of_variable): Ditto. * utils.c (internal_vproblem): Ditto. * solib-aix5.c (build_so_list_from_mapfile): Ditto. * remote.c (add_packet_config_cmd): Ditto. * remote-rdp.c (rdp_set_command_line): Ditto. * regcache.c (regcache_dump): Ditto. * frv-tdep.c (new_variant, new_variant): Ditto. * fbsd-proc.c (child_pid_to_exec_file): Ditto. (fbsd_find_memory_regions): Ditto. * breakpoint.c (create_thread_event_breakpoint) (create_breakpoints): Ditto. * aix-thread.c (aix_thread_pid_to_str): Ditto. * ada-lang.c (is_package_name): Ditto. Also delete xmalloc call. Index: doc/ChangeLog 2004-06-26 Andrew Cagney * gdbint.texinfo (Coding): Replace xasprintf with xstrprintf. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ae7e0b5dbee..51d6b3647f6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +2004-06-28 Andrew Cagney + + * xcoffsolib.c (xcoff_solib_address): Replace xasprintf with + xstrprintf. + * varobj.c (varobj_gen_name, create_child, c_name_of_child) + (c_value_of_variable): Ditto. + * utils.c (internal_vproblem): Ditto. + * solib-aix5.c (build_so_list_from_mapfile): Ditto. + * remote.c (add_packet_config_cmd): Ditto. + * remote-rdp.c (rdp_set_command_line): Ditto. + * regcache.c (regcache_dump): Ditto. + * frv-tdep.c (new_variant, new_variant): Ditto. + * fbsd-proc.c (child_pid_to_exec_file): Ditto. + (fbsd_find_memory_regions): Ditto. + * breakpoint.c (create_thread_event_breakpoint) + (create_breakpoints): Ditto. + * aix-thread.c (aix_thread_pid_to_str): Ditto. + * ada-lang.c (is_package_name): Ditto. Also delete xmalloc call. + 2004-06-28 Joel Brobecker * ada-lang.c: Re-indent file, with some massaging to help indent diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 57f37333195..6ec5044c01e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4369,8 +4369,7 @@ is_package_name (const char *name) if (strstr (name, "__") != NULL) return 0; - fun_name = (char *) alloca (strlen (name) + 5 + 1); - xasprintf (&fun_name, "_ada_%s", name); + fun_name = xstrprintf ("_ada_%s", name); return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL); } diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 05493ae0f98..e5e8a9aac4e 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1629,10 +1629,10 @@ aix_thread_pid_to_str (ptid_t ptid) return base_target.to_pid_to_str (ptid); /* Free previous return value; a new one will be allocated by - xasprintf(). */ + xstrprintf(). */ xfree (ret); - xasprintf (&ret, "Thread %ld", ptid_get_tid (ptid)); + ret = xstrprintf ("Thread %ld", ptid_get_tid (ptid)); return ret; } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 336264d5efd..018f4646531 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4258,7 +4258,7 @@ create_thread_event_breakpoint (CORE_ADDR address) b->enable_state = bp_enabled; /* addr_string has to be used or breakpoint_re_set will delete me. */ - xasprintf (&b->addr_string, "*0x%s", paddr (b->loc->address)); + b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address)); return b; } @@ -4902,7 +4902,7 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string, else /* addr_string has to be used or breakpoint_re_set will delete me. */ - xasprintf (&b->addr_string, "*0x%s", paddr (b->loc->address)); + b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address)); b->cond_string = cond_string[i]; b->ignore_count = ignore_count; b->enable_state = bp_enabled; diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 4ab61047b41..5a0b8107606 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2004-06-26 Andrew Cagney + + * gdbint.texinfo (Coding): Replace xasprintf with xstrprintf. + 2004-06-20 Andrew Cagney * gdbint.texinfo (Target Architecture Definition): Deprecate diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 5d1ba7f3270..a3821b59b03 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -4942,7 +4942,7 @@ allocation of small temporary values (such as strings). restrict the memory being allocated to no more than a few kilobytes.} @value{GDBN} uses the string function @code{xstrdup} and the print -function @code{xasprintf}. +function @code{xstrprintf}. @emph{Pragmatics: @code{asprintf} and @code{strdup} can fail. Print functions such as @code{sprintf} are very prone to buffer overflow diff --git a/gdb/fbsd-proc.c b/gdb/fbsd-proc.c index 8eed4ccb2cd..f021d275b9a 100644 --- a/gdb/fbsd-proc.c +++ b/gdb/fbsd-proc.c @@ -38,7 +38,7 @@ child_pid_to_exec_file (int pid) char *path; char *buf; - xasprintf (&path, "/proc/%d/file", pid); + path = xstrprintf ("/proc/%d/file", pid); buf = xcalloc (MAXPATHLEN, sizeof (char)); make_cleanup (xfree, path); make_cleanup (xfree, buf); @@ -82,7 +82,7 @@ fbsd_find_memory_regions (int (*func) (CORE_ADDR, unsigned long, char protection[4]; int read, write, exec; - xasprintf (&mapfilename, "/proc/%ld/map", (long) pid); + mapfilename = xstrprintf ("/proc/%ld/map", (long) pid); mapfile = fopen (mapfilename, "r"); if (mapfile == NULL) error ("Couldn't open %s\n", mapfilename); diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 77f137452a0..9b7524c2bb0 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -197,7 +197,7 @@ new_variant (void) for (r = acc0_regnum; r <= acc7_regnum; r++) { char *buf; - xasprintf (&buf, "acc%d", r - acc0_regnum); + buf = xstrprintf ("acc%d", r - acc0_regnum); var->register_names[r] = buf; } @@ -210,7 +210,7 @@ new_variant (void) for (r = accg0_regnum; r <= accg7_regnum; r++) { char *buf; - xasprintf (&buf, "accg%d", r - accg0_regnum); + buf = xstrprintf ("accg%d", r - accg0_regnum); var->register_names[r] = buf; } diff --git a/gdb/regcache.c b/gdb/regcache.c index 4058a986071..ceeaca63fe1 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1572,7 +1572,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, char *n; if (!footnote_register_type_name_null) footnote_register_type_name_null = ++footnote_nr; - xasprintf (&n, "*%d", footnote_register_type_name_null); + n = xstrprintf ("*%d", footnote_register_type_name_null); make_cleanup (xfree, n); t = n; } diff --git a/gdb/remote-rdp.c b/gdb/remote-rdp.c index 68e69326f2e..53604678f20 100644 --- a/gdb/remote-rdp.c +++ b/gdb/remote-rdp.c @@ -721,7 +721,7 @@ rdp_set_command_line (char *command, char *args) if (commandline != NULL) xfree (commandline); - xasprintf (&commandline, "%s %s", command, args); + commandline = xstrprintf ("%s %s", command, args); } static void diff --git a/gdb/remote.c b/gdb/remote.c index 962a58db49b..f754f8048dd 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -651,12 +651,12 @@ add_packet_config_cmd (struct packet_config *config, config->title = title; config->detect = AUTO_BOOLEAN_AUTO; config->support = PACKET_SUPPORT_UNKNOWN; - xasprintf (&set_doc, "Set use of remote protocol `%s' (%s) packet", - name, title); - xasprintf (&show_doc, "Show current use of remote protocol `%s' (%s) packet", - name, title); + set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet", + name, title); + show_doc = xstrprintf ("Show current use of remote protocol `%s' (%s) packet", + name, title); /* set/show TITLE-packet {auto,on,off} */ - xasprintf (&cmd_name, "%s-packet", title); + cmd_name = xstrprintf ("%s-packet", title); add_setshow_auto_boolean_cmd (cmd_name, class_obscure, &config->detect, set_doc, show_doc, set_func, show_func, @@ -665,7 +665,7 @@ add_packet_config_cmd (struct packet_config *config, if (legacy) { char *legacy_name; - xasprintf (&legacy_name, "%s-packet", name); + legacy_name = xstrprintf ("%s-packet", name); add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, set_remote_list); add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, diff --git a/gdb/solib-aix5.c b/gdb/solib-aix5.c index 1a8c9dfeea9..54b1199b92a 100644 --- a/gdb/solib-aix5.c +++ b/gdb/solib-aix5.c @@ -193,7 +193,7 @@ build_so_list_from_mapfile (int pid, long match_mask, long match_val) /* Open the map file */ - xasprintf (&map_pathname, "/proc/%d/map", pid); + map_pathname = xstrprintf ("/proc/%d/map", pid); map_fd = open (map_pathname, O_RDONLY); xfree (map_pathname); if (map_fd < 0) diff --git a/gdb/utils.c b/gdb/utils.c index 504890ebf15..f1c2fe44393 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -753,7 +753,7 @@ internal_vproblem (struct internal_problem *problem, { char *msg; xvasprintf (&msg, fmt, ap); - xasprintf (&reason, "\ + reason = xstrprintf ("\ %s:%d: %s: %s\n\ A problem internal to GDB has been detected,\n\ further debugging may prove unreliable.", file, line, problem->name, msg); diff --git a/gdb/varobj.c b/gdb/varobj.c index c662518c82f..ea4fa0118c1 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -549,7 +549,7 @@ varobj_gen_name (void) /* generate a name for this object */ id++; - xasprintf (&obj_name, "var%d", id); + obj_name = xstrprintf ("var%d", id); return obj_name; } @@ -1254,7 +1254,7 @@ create_child (struct varobj *parent, int index, char *name) child->error = 1; child->parent = parent; child->root = parent->root; - xasprintf (&childs_name, "%s.%s", parent->obj_name, name); + childs_name = xstrprintf ("%s.%s", parent->obj_name, name); child->obj_name = childs_name; install_variable (child); @@ -1837,7 +1837,7 @@ c_name_of_child (struct varobj *parent, int index) switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: - xasprintf (&name, "%d", index); + name = xstrprintf ("%d", index); break; case TYPE_CODE_STRUCT: @@ -1856,7 +1856,7 @@ c_name_of_child (struct varobj *parent, int index) break; default: - xasprintf (&name, "*%s", parent->name); + name = xstrprintf ("*%s", parent->name); break; } break; @@ -2070,7 +2070,7 @@ c_value_of_variable (struct varobj *var) case TYPE_CODE_ARRAY: { char *number; - xasprintf (&number, "[%d]", var->num_children); + number = xstrprintf ("[%d]", var->num_children); return (number); } /* break; */ diff --git a/gdb/xcoffsolib.c b/gdb/xcoffsolib.c index 99d2cc8e8f7..62426c92fb0 100644 --- a/gdb/xcoffsolib.c +++ b/gdb/xcoffsolib.c @@ -48,11 +48,11 @@ xcoff_solib_address (CORE_ADDR addr) if (vp->tstart <= addr && addr < vp->tend) { xfree (buffer); - xasprintf (&buffer, "%s%s%s%s", - vp->name, - *vp->member ? "(" : "", - vp->member, - *vp->member ? ")" : ""); + buffer = xstrprintf ("%s%s%s%s", + vp->name, + *vp->member ? "(" : "", + vp->member, + *vp->member ? ")" : ""); return buffer; } return NULL;