From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jV8WCz3dAmF0RwAAWB0awg (envelope-from ) for ; Thu, 29 Jul 2021 12:54:21 -0400 Received: by simark.ca (Postfix, from userid 112) id 1E4A41EDFB; Thu, 29 Jul 2021 12:54:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 75F5B1E4A3 for ; Thu, 29 Jul 2021 12:54:20 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 07AAD3AA7C89 for ; Thu, 29 Jul 2021 16:54:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07AAD3AA7C89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1627577660; bh=OLSJlq3vxHqBdVrM8NIhtcabMX5Sof269/xHhca/Dog=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ewfOqsiV4l9BRrecF3RRVS4ryzYk1Qq6yQavmKRTc2AZHY9MwTuakTiBDKRz2MFKC 6tzKKPQeRTvKajD8BjvTHA5ueftSlMDnb5Kio+SGQsRJjPHybdAEHMjSm7ZcXlXAx/ isSqbJ4T144PwKeoujTJRoMlIApaNCmjHpTz/AFk= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5BED3385381D for ; Thu, 29 Jul 2021 16:54:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5BED3385381D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 16TGrpFo028745 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 12:53:56 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 16TGrpFo028745 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id AD8FB1E4A3; Thu, 29 Jul 2021 12:53:51 -0400 (EDT) Subject: Re: [PATCH v3 1/3] gdbtypes: return value from get_unsigned_type_max To: George Barrett , gdb-patches@sourceware.org References: <6-nou03zjdt7znv7en-rj/.p1fg6ovruu-op5_qcpmqs&zn3c/5n@mail.bob131.so> Message-ID: <133a963e-2517-2ecb-2eeb-0df078a43f81@polymtl.ca> Date: Thu, 29 Jul 2021 12:53:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <6-nou03zjdt7znv7en-rj/.p1fg6ovruu-op5_qcpmqs&zn3c/5n@mail.bob131.so> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 29 Jul 2021 16:53:51 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Thanks, I'll push it with this small change: On 2021-07-29 11:12 a.m., George Barrett via Gdb-patches wrote: > Changes the signature of get_unsigned_type_max to return the computed > value rather than returning void and writing the value into a pointer > passed by the caller. > > gdb/ChangeLog: > > 2021-07-30 George Barrett > > * gdbtypes.h (get_unsigned_type_max): Change signature to > return the result instead of accepting a pointer argument in > which to store the result. > * gdbtypes.c (get_unsigned_type_max): Likewise. > * guile/scm-math.c (vlscm_convert_typed_number): Update caller > of get_unsigned_type_max. > (vlscm_integer_fits_p): Likewise. Note that we don't use ChangeLog files anymore, so you don't have to write these. > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index 1a261719422..12c7042e10a 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -1894,8 +1894,8 @@ lookup_struct_elt_type (struct type *type, const char *name, int noerr) > /* Store in *MAX the largest number representable by unsigned integer type > TYPE. */ I'll update this comment. > > -void > -get_unsigned_type_max (struct type *type, ULONGEST *max) > +ULONGEST > +get_unsigned_type_max (struct type *type) > { > unsigned int n; > > @@ -1905,7 +1905,7 @@ get_unsigned_type_max (struct type *type, ULONGEST *max) > > /* Written this way to avoid overflow. */ > n = TYPE_LENGTH (type) * TARGET_CHAR_BIT; > - *max = ((((ULONGEST) 1 << (n - 1)) - 1) << 1) | 1; > + return ((((ULONGEST) 1 << (n - 1)) - 1) << 1) | 1; > } > > /* Store in *MIN, *MAX the smallest and largest numbers representable by > diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h > index d754f2fcd36..b47644b210e 100644 > --- a/gdb/gdbtypes.h > +++ b/gdb/gdbtypes.h > @@ -2519,7 +2519,7 @@ extern struct type *lookup_unsigned_typename (const struct language_defn *, > extern struct type *lookup_signed_typename (const struct language_defn *, > const char *); > > -extern void get_unsigned_type_max (struct type *, ULONGEST *); > +extern ULONGEST get_unsigned_type_max (struct type *); > > extern void get_signed_type_minmax (struct type *, LONGEST *, LONGEST *); > > diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c > index d9fd6718196..f1c032b6efa 100644 > --- a/gdb/guile/scm-math.c > +++ b/gdb/guile/scm-math.c > @@ -529,9 +529,7 @@ vlscm_convert_typed_number (const char *func_name, int obj_arg_pos, SCM obj, > { > if (type->is_unsigned ()) > { > - ULONGEST max; > - > - get_unsigned_type_max (type, &max); > + ULONGEST max = get_unsigned_type_max (type); > if (!scm_is_unsigned_integer (obj, 0, max)) > { > *except_scmp > @@ -580,7 +578,7 @@ vlscm_integer_fits_p (SCM obj, struct type *type) > /* If scm_is_unsigned_integer can't work with this type, just punt. */ > if (TYPE_LENGTH (type) > sizeof (uintmax_t)) > return 0; > - get_unsigned_type_max (type, &max); > + max = get_unsigned_type_max (type); > return scm_is_unsigned_integer (obj, 0, max); And move the declaration of `max` where it's initialized. Thanks, Simon