From patchwork Wed Feb 19 14:57:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 38226 Received: (qmail 58112 invoked by alias); 19 Feb 2020 14:57:36 -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 58102 invoked by uid 89); 19 Feb 2020 14:57:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 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=H*r:10024, 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; Wed, 19 Feb 2020 14:57:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C729256047; Wed, 19 Feb 2020 09:57:30 -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 RPmfJH+h+9VA; Wed, 19 Feb 2020 09:57:30 -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 8295E56042; Wed, 19 Feb 2020 09:57:30 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Remove useless NULL check in python.c Date: Wed, 19 Feb 2020 07:57:28 -0700 Message-Id: <20200219145728.14136-1-tromey@adacore.com> MIME-Version: 1.0 I noticed that do_start_initialization, in python.c, checks the result of xmalloc. However, xmalloc cannot fail, so this check is useless. This patch also changes the code to use XNEWVEC. gdb/ChangeLog 2020-02-19 Tom Tromey * python/python.c (do_start_initialization): Use XNEWVEC. Remove NULL check. --- gdb/ChangeLog | 5 +++++ gdb/python/python.c | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index 27d6042c618..fbbc159ede3 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1679,12 +1679,7 @@ do_start_initialization () std::string oldloc = setlocale (LC_ALL, NULL); setlocale (LC_ALL, ""); progsize = strlen (progname.get ()); - progname_copy = (wchar_t *) xmalloc ((progsize + 1) * sizeof (wchar_t)); - if (!progname_copy) - { - fprintf (stderr, "out of memory\n"); - return false; - } + progname_copy = XNEWVEC (wchar_t, progsize + 1); count = mbstowcs (progname_copy, progname.get (), progsize + 1); if (count == (size_t) -1) {