public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Simplify print_sys_errmsg
@ 2019-11-01 16:40 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-11-01 16:40 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5df96a4e6e8f1521274acb5beb54063c35aeec6e

commit 5df96a4e6e8f1521274acb5beb54063c35aeec6e
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Oct 31 16:46:16 2019 -0600

    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

Diff:
---
 gdb/ChangeLog | 4 ++++
 gdb/utils.c   | 7 +------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 500c486..34e332b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 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.
 
 2019-11-01  Christian Biesinger  <cbiesinger@google.com>
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.  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-01 16:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 16:40 [binutils-gdb] Simplify print_sys_errmsg Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).