From patchwork Thu Oct 31 22:51:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35547 Received: (qmail 75080 invoked by alias); 31 Oct 2019 22:51:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 75019 invoked by uid 89); 31 Oct 2019 22:51:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Oct 2019 22:51:29 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 135EB20468; Thu, 31 Oct 2019 18:51:28 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id E29042047F for ; Thu, 31 Oct 2019 18:51:23 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id CAE2E25B28 for ; Thu, 31 Oct 2019 18:51:23 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Thu, 31 Oct 2019 18:51:23 -0400 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Simplify print_sys_errmsg X-Gerrit-Change-Id: I5e9a042d957d44d8d76477729da33feb6f11ec37 X-Gerrit-Change-Number: 479 X-Gerrit-ChangeURL: X-Gerrit-Commit: 98d26e711a7c113419e070dd9af3f65923807bbb References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/479 ...................................................................... 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-10-31 Tom Tromey * utils.c (print_sys_errmsg): Simplify. Change-Id: I5e9a042d957d44d8d76477729da33feb6f11ec37 --- M gdb/ChangeLog M gdb/utils.c 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f34dbc..e0bd948 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2019-10-31 Tom Tromey + * utils.c (print_sys_errmsg): Simplify. + +2019-10-31 Tom Tromey + * gdbsupport/mingw-strerror.c (safe_strerror): Constify result. * gdbsupport/gdb-dlfcn.c (gdb_dlopen): Update. 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 @@ 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. */