From patchwork Wed Sep 25 15:50:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34654 Received: (qmail 54398 invoked by alias); 25 Sep 2019 15:50:35 -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 54385 invoked by uid 89); 25 Sep 2019 15:50:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2379, Copy X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.160.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Sep 2019 15:50:33 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 6F2BA14D09 for ; Wed, 25 Sep 2019 10:50:32 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id D9Ymiep1d90onD9YmiLPVf; Wed, 25 Sep 2019 10:50:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6omTLyZJwmDmJtU2KJfZlALmCKcYoEnANXBpoVlyVvM=; b=EhlXdg004UKj8mjQL/1iHGlGZ7 XLlyHl6c5lomMYGc2UWt/0b9X2YYo1EKuayYv1Ai800UXQeAiwFdaKIOIe6klK9J85RyMuGKCuJqj J7BFN3X8tDzoDmnY4cZebqHev; Received: from 71-218-73-27.hlrn.qwest.net ([71.218.73.27]:42984 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iD9Ym-0037Ob-7S; Wed, 25 Sep 2019 10:50:32 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Remove make_hex_string Date: Wed, 25 Sep 2019 09:50:29 -0600 Message-Id: <20190925155029.26764-1-tom@tromey.com> I noticed that make_hex_string does essentially the same thing as bin2hex, and furthermore is only called in a single spot. This patch removes make_hex_string. Tested by the builtbot. gdb/ChangeLog 2019-09-25 Tom Tromey * python/py-objfile.c (objfpy_get_build_id): Use bin2hex. * utils.h (make_hex_string): Don't declare. * utils.c (make_hex_string): Remove. --- gdb/ChangeLog | 6 ++++++ gdb/python/py-objfile.c | 5 ++--- gdb/utils.c | 16 ---------------- gdb/utils.h | 5 ----- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 2c548450b4d..517ed56dc7c 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -141,10 +141,9 @@ objfpy_get_build_id (PyObject *self, void *closure) if (build_id != NULL) { - gdb::unique_xmalloc_ptr hex_form - (make_hex_string (build_id->data, build_id->size)); + std::string hex_form = bin2hex (build_id->data, build_id->size); - return host_string_to_python_string (hex_form.get ()).release (); + return host_string_to_python_string (hex_form.c_str ()).release (); } Py_RETURN_NONE; diff --git a/gdb/utils.c b/gdb/utils.c index b2535ebefd3..154fcd97e2a 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -736,22 +736,6 @@ gdb_print_host_address_1 (const void *addr, struct ui_file *stream) fprintf_filtered (stream, "%s", host_address_to_string (addr)); } -/* See utils.h. */ - -char * -make_hex_string (const gdb_byte *data, size_t length) -{ - char *result = (char *) xmalloc (length * 2 + 1); - char *p; - size_t i; - - p = result; - for (i = 0; i < length; ++i) - p += xsnprintf (p, 3, "%02x", data[i]); - *p = '\0'; - return result; -} - /* An RAII class that sets up to handle input and then tears down diff --git a/gdb/utils.h b/gdb/utils.h index 7cdc73ef54f..b0b5573239e 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -540,11 +540,6 @@ extern void warn_cant_dump_core (const char *reason); extern void dump_core (void); -/* Return the hex string form of LENGTH bytes of DATA. - Space for the result is malloc'd, caller must free. */ - -extern char *make_hex_string (const gdb_byte *data, size_t length); - /* Copy NBITS bits from SOURCE to DEST starting at the given bit offsets. Use the bit order as specified by BITS_BIG_ENDIAN. Source and destination buffers must not overlap. */