mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-23 13:21:43 +08:00
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
This commit is contained in:
parent
b74816496d
commit
5df96a4e6e
@ -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.
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user