From patchwork Tue Dec 10 20:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36689 Received: (qmail 98784 invoked by alias); 10 Dec 2019 20:35:07 -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 98776 invoked by uid 89); 10 Dec 2019 20:35:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 20:35:05 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 311AC560C8; Tue, 10 Dec 2019 15:35:04 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id J5LZLbs0FfYu; Tue, 10 Dec 2019 15:35:04 -0500 (EST) Received: from murgatroyd.Home (75-166-123-50.hlrn.qwest.net [75.166.123.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id DF95A560B8; Tue, 10 Dec 2019 15:35:03 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove some calls to malloc_failure Date: Tue, 10 Dec 2019 13:35:02 -0700 Message-Id: <20191210203502.30392-1-tromey@adacore.com> MIME-Version: 1.0 I noticed a couple of spots that call malloc_failure, but that don't need to. * In xml-support.c, "concat" uses xmalloc, so cannot return NULL. * In utils.c, "buildargv" also uses xmalloc, so can only return NULL if the argument is empty. Tested by the buildbot. gdb/ChangeLog 2019-12-10 Tom Tromey * xml-support.c (xml_fetch_content_from_file): Don't call malloc_failure. * utils.h (class gdb_argv): Remove malloc_failure comment. * utils.c (gdb_argv::reset): Don't call malloc_failure. Change-Id: I59483620deb6609ccf2f024d94a29113bb62d1a9 --- gdb/ChangeLog | 7 +++++++ gdb/utils.c | 3 --- gdb/utils.h | 5 +---- gdb/xml-support.c | 2 -- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gdb/utils.c b/gdb/utils.c index f7fae35729b..0b8ec02abe6 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3033,9 +3033,6 @@ gdb_argv::reset (const char *s) { char **argv = buildargv (s); - if (s != NULL && argv == NULL) - malloc_failure (0); - freeargv (m_argv); m_argv = argv; } diff --git a/gdb/utils.h b/gdb/utils.h index c8337f23017..71860191403 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -146,10 +146,7 @@ public: } /* A constructor that calls buildargv on STR. STR may be NULL, in - which case this object is initialized with a NULL array. If - buildargv fails due to out-of-memory, call malloc_failure. - Therefore, the value is guaranteed to be non-NULL, unless the - parameter itself is NULL. */ + which case this object is initialized with a NULL array. */ explicit gdb_argv (const char *str) : m_argv (NULL) diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 915be76066d..f5a14275457 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -977,8 +977,6 @@ xml_fetch_content_from_file (const char *filename, void *baton) { char *fullname = concat (dirname, "/", filename, (char *) NULL); - if (fullname == NULL) - malloc_failure (0); file = gdb_fopen_cloexec (fullname, FOPEN_RT); xfree (fullname); }