Simplify print_sys_errmsg
authorTom Tromey <tromey@adacore.com>
Thu, 31 Oct 2019 22:46:16 +0000 (16:46 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 1 Nov 2019 16:34:21 +0000 (10:34 -0600)
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

gdb/ChangeLog
gdb/utils.c

index 500c4868c8f44a37c3700afce54f9b629e1cac4f..34e332b03341fab673c2012c8c2f6fe6cae791c3 100644 (file)
@@ -1,3 +1,7 @@
+2019-11-01  Tom Tromey  <tromey@adacore.com>
+
+       * utils.c (print_sys_errmsg): Simplify.
+
 2019-11-01  Tom Tromey  <tromey@adacore.com>
 
        * gdbsupport/mingw-strerror.c (safe_strerror): Constify result.
index e06eeddeeff9b47c034b11a10e7ffa4bbc074ea9..f7fae35729b7cfb4d4573b68616a174b1fba66c5 100644 (file)
@@ -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.  */
This page took 0.032447 seconds and 4 git commands to generate.