From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5E2FF3858D20 for ; Fri, 4 Feb 2022 11:37:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5E2FF3858D20 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-GtFBFYcoOuyALQPK_VTLZw-1; Fri, 04 Feb 2022 06:37:49 -0500 X-MC-Unique: GtFBFYcoOuyALQPK_VTLZw-1 Received: by mail-wr1-f70.google.com with SMTP id k12-20020adfe3cc000000b001d6806dfde1so1888924wrm.16 for ; Fri, 04 Feb 2022 03:37:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Pjh1IBvN2PKRcAQOSYoJ/fHHMtcQmc6O9PEv0VHUDeg=; b=k84Y0OGz5Ho56M+l1Zm0VzZjxr06BXaGWx8IcXMSDP6VKJ1yCuiui1xuYkX8/WYLjN PPmORPln6jL+uQmDTNEtggxRliCrGWO461/1sRcwAHfHzHulH+f2YEWaeQv9hvbblif0 5Jf/b+uiF4GaA+FTWapekU1FxnG18ZAhHJMMeRSpg8aGMCiPNA6hbPpKvmbzwhmR5Tbo gMfTUAxzIeolU3VZ/S6K6BMQLLdeT5XElGIzcOVl1MzUtUeDvWv5z9hcd+0vHIdCdDQN GnABO7bLmjB1sNNR/8M4ybFdxWPyioyBdx8ZgnTAAQJpaBoDNqV5pvOROeWR6ABWGN5r XBVw== X-Gm-Message-State: AOAM531d1C+rgLodxu7qc7nkv/mrLh94ug9xbFH7EgnA4sTRHyRmf1AC P/muMimbeqi9iUTNDaUzsdztbn97lMZ0QgL8bnQeasWUs724ulNFDvPUZNbfp5omIujXybOCy3x s0zy7ZhPRkSXl+Jx9Aszsjg== X-Received: by 2002:a05:600c:34cf:: with SMTP id d15mr1863733wmq.73.1643974667615; Fri, 04 Feb 2022 03:37:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkQetCv8Ihk0Z7EWONxtJj4c7UBhXqMQbpoZ4isXmTKeqF3/rVFkDHcgI5mHzH1XO4lYDoSw== X-Received: by 2002:a05:600c:34cf:: with SMTP id d15mr1863714wmq.73.1643974667301; Fri, 04 Feb 2022 03:37:47 -0800 (PST) Received: from localhost (host86-140-92-93.range86-140.btcentralplus.com. [86.140.92.93]) by smtp.gmail.com with ESMTPSA id s9sm1751066wrr.84.2022.02.04.03.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 03:37:46 -0800 (PST) Date: Fri, 4 Feb 2022 11:37:44 +0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Remove host_hex_value Message-ID: <20220204113744.GA1917497@redhat.com> References: <20220203191249.890726-1-tromey@adacore.com> MIME-Version: 1.0 In-Reply-To: <20220203191249.890726-1-tromey@adacore.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 11:37:28 up 11 days, 2:24, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-20.9 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2022 11:37:52 -0000 * Tom Tromey via Gdb-patches [2022-02-03 12:12:49 -0700]: > I noticed that host_hex_value is redundant, because gdbsupport already > has fromhex. This patch removes the former in favor of the latter. > > Regression tested on x86-64 Fedora 34. LGTM. Thanks, Andrew > --- > gdb/c-lang.c | 6 +++--- > gdb/charset.c | 14 -------------- > gdb/charset.h | 5 ----- > gdb/mi/mi-parse.c | 4 ++-- > gdb/python/py-objfile.c | 2 +- > gdb/utils.c | 4 ++-- > 6 files changed, 8 insertions(+), 27 deletions(-) > > diff --git a/gdb/c-lang.c b/gdb/c-lang.c > index ed7554fadea..1f7cac7bef1 100644 > --- a/gdb/c-lang.c > +++ b/gdb/c-lang.c > @@ -410,7 +410,7 @@ convert_ucn (const char *p, const char *limit, const char *dest_charset, > int i; > > for (i = 0; i < length && p < limit && ISXDIGIT (*p); ++i, ++p) > - result = (result << 4) + host_hex_value (*p); > + result = (result << 4) + fromhex (*p); > > for (i = 3; i >= 0; --i) > { > @@ -454,7 +454,7 @@ convert_octal (struct type *type, const char *p, > i < 3 && p < limit && ISDIGIT (*p) && *p != '8' && *p != '9'; > ++i) > { > - value = 8 * value + host_hex_value (*p); > + value = 8 * value + fromhex (*p); > ++p; > } > > @@ -476,7 +476,7 @@ convert_hex (struct type *type, const char *p, > > while (p < limit && ISXDIGIT (*p)) > { > - value = 16 * value + host_hex_value (*p); > + value = 16 * value + fromhex (*p); > ++p; > } > > diff --git a/gdb/charset.c b/gdb/charset.c > index bf205ae087c..84c60a4e5d6 100644 > --- a/gdb/charset.c > +++ b/gdb/charset.c > @@ -463,20 +463,6 @@ host_letter_to_control_character (char c) > return c & 0237; > } > > -/* Convert a host character, C, to its hex value. C must already have > - been validated using isxdigit. */ > - > -int > -host_hex_value (char c) > -{ > - if (isdigit (c)) > - return c - '0'; > - if (c >= 'a' && c <= 'f') > - return 10 + c - 'a'; > - gdb_assert (c >= 'A' && c <= 'F'); > - return 10 + c - 'A'; > -} > - > > /* Public character management functions. */ > > diff --git a/gdb/charset.h b/gdb/charset.h > index 871f0d856ac..7a7041f10f2 100644 > --- a/gdb/charset.h > +++ b/gdb/charset.h > @@ -159,9 +159,4 @@ class wchar_iterator > character. */ > char host_letter_to_control_character (char c); > > -/* Convert a hex digit character to its numeric value. E.g., 'f' is > - converted to 15. This function assumes that C is a valid hex > - digit. Both upper- and lower-case letters are recognized. */ > -int host_hex_value (char c); > - > #endif /* CHARSET_H */ > diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c > index d5febced153..dfa7b462714 100644 > --- a/gdb/mi/mi-parse.c > +++ b/gdb/mi/mi-parse.c > @@ -57,7 +57,7 @@ mi_parse_escape (const char **string_ptr) > case '6': > case '7': > { > - int i = host_hex_value (c); > + int i = fromhex (c); > int count = 0; > > while (++count < 3) > @@ -67,7 +67,7 @@ mi_parse_escape (const char **string_ptr) > { > (*string_ptr)++; > i *= 8; > - i += host_hex_value (c); > + i += fromhex (c); > } > else > { > diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c > index 48d2eb306d1..8c568799843 100644 > --- a/gdb/python/py-objfile.c > +++ b/gdb/python/py-objfile.c > @@ -550,7 +550,7 @@ objfpy_build_id_matches (const struct bfd_build_id *build_id, > for (i = 0; i < build_id->size; ++i) > { > char c1 = string[i * 2], c2 = string[i * 2 + 1]; > - int byte = (host_hex_value (c1) << 4) | host_hex_value (c2); > + int byte = (fromhex (c1) << 4) | fromhex (c2); > > if (byte != build_id->data[i]) > return 0; > diff --git a/gdb/utils.c b/gdb/utils.c > index 152fa9b630a..dcb42138d39 100644 > --- a/gdb/utils.c > +++ b/gdb/utils.c > @@ -1078,7 +1078,7 @@ parse_escape (struct gdbarch *gdbarch, const char **string_ptr) > case '6': > case '7': > { > - int i = host_hex_value (c); > + int i = fromhex (c); > int count = 0; > while (++count < 3) > { > @@ -1087,7 +1087,7 @@ parse_escape (struct gdbarch *gdbarch, const char **string_ptr) > { > (*string_ptr)++; > i *= 8; > - i += host_hex_value (c); > + i += fromhex (c); > } > else > { > -- > 2.31.1 >