From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.bob131.so (server2.bob131.so [128.199.153.143]) by sourceware.org (Postfix) with ESMTPS id 9336E39B3C3B for ; Thu, 29 Jul 2021 15:12:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9336E39B3C3B Received: from internal.mail.bob131.so (localhost [127.0.0.1]) by mail.bob131.so (Postfix) with ESMTP id 0AA0E3EA36; Thu, 29 Jul 2021 15:12:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.bob131.so 0AA0E3EA36 Date: Fri, 30 Jul 2021 01:12:03 +1000 From: George Barrett To: gdb-patches@sourceware.org Cc: George Barrett Subject: [PATCH v3 1/3] gdbtypes: return value from get_unsigned_type_max Message-ID: <6-nou03zjdt7znv7en-rj/.p1fg6ovruu-op5_qcpmqs&zn3c/5n@mail.bob131.so> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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: Thu, 29 Jul 2021 15:12:10 -0000 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. --- gdb/gdbtypes.c | 6 +++--- gdb/gdbtypes.h | 2 +- gdb/guile/scm-math.c | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) 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. */ -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); } else -- 2.31.1