diff options
author | George Barrett <bob@bob131.so> | 2021-07-30 01:12:03 +1000 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-29 12:54:14 -0400 |
commit | c3c1e6459f89167fc01de9376c6b34574d710278 (patch) | |
tree | 9887eca9da6342468431adc210fe7e88e9dd473e | |
parent | cd026728f3bcba878293f9c38f8760512755ed73 (diff) | |
download | binutils-c3c1e6459f89167fc01de9376c6b34574d710278.zip binutils-c3c1e6459f89167fc01de9376c6b34574d710278.tar.gz binutils-c3c1e6459f89167fc01de9376c6b34574d710278.tar.bz2 |
gdbtypes: return value from get_unsigned_type_max
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 <bob@bob131.so>
* 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.
Change-Id: Ibb1bf0c0fa181fac7853147dfde082a7d1ae2323
-rw-r--r-- | gdb/gdbtypes.c | 9 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 2 | ||||
-rw-r--r-- | gdb/guile/scm-math.c | 9 |
3 files changed, 8 insertions, 12 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1a26171..609de23 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1891,11 +1891,10 @@ lookup_struct_elt_type (struct type *type, const char *name, int noerr) return NULL; } -/* Store in *MAX the largest number representable by unsigned integer type - TYPE. */ +/* Return 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 +1904,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 d754f2f..b47644b 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 d9fd671..15b7247 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 @@ -575,12 +573,11 @@ vlscm_integer_fits_p (SCM obj, struct type *type) { if (type->is_unsigned ()) { - ULONGEST max; - /* 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); + + ULONGEST max = get_unsigned_type_max (type); return scm_is_unsigned_integer (obj, 0, max); } else |