aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-10-31 16:46:16 -0600
committerTom Tromey <tromey@adacore.com>2019-11-01 10:34:21 -0600
commit5df96a4e6e8f1521274acb5beb54063c35aeec6e (patch)
tree6bfc777b7df9c85cce9cdb671acb9e54703b9f02 /gdb/utils.c
parentb74816496d5113596dd80bd071ed9bcf152c96cd (diff)
downloadgdb-5df96a4e6e8f1521274acb5beb54063c35aeec6e.zip
gdb-5df96a4e6e8f1521274acb5beb54063c35aeec6e.tar.gz
gdb-5df96a4e6e8f1521274acb5beb54063c35aeec6e.tar.bz2
Simplify print_sys_errmsg
On irc, Christian pointed out that print_sys_errmsg could be simplified by avoiding alloca entirely. This patch implements this. gdb/ChangeLog 2019-11-01 Tom Tromey <tromey@adacore.com> * utils.c (print_sys_errmsg): Simplify. Change-Id: Ic399dade274ea61b63ef0540b3a3be2f0f80160a
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index e06eedd..f7fae35 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -629,15 +629,10 @@ void
print_sys_errmsg (const char *string, int errcode)
{
const char *err = safe_strerror (errcode);
- char *combined = (char *) alloca (strlen (err) + strlen (string) + 3);
- strcpy (combined, string);
- strcat (combined, ": ");
- strcat (combined, err);
-
/* We want anything which was printed on stdout to come out first, before
this message. */
gdb_flush (gdb_stdout);
- fprintf_unfiltered (gdb_stderr, "%s.\n", combined);
+ fprintf_unfiltered (gdb_stderr, "%s: %s.\n", string, err);
}
/* Control C eventually causes this to be called, at a convenient time. */