Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: George Barrett <bob@bob131.so>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3 1/3] gdbtypes: return value from get_unsigned_type_max
Date: Thu, 29 Jul 2021 12:53:51 -0400	[thread overview]
Message-ID: <133a963e-2517-2ecb-2eeb-0df078a43f81@polymtl.ca> (raw)
In-Reply-To: <6-nou03zjdt7znv7en-rj/.p1fg6ovruu-op5_qcpmqs&zn3c/5n@mail.bob131.so>

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  <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.

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

  parent reply	other threads:[~2021-07-29 16:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 15:12 George Barrett via Gdb-patches
2021-07-29 15:12 ` [PATCH v3 2/3] guile: fix make-value with pointer type George Barrett via Gdb-patches
2021-07-29 16:55   ` Simon Marchi via Gdb-patches
2021-07-29 15:12 ` [PATCH v3 3/3] guile/scm-math: indentation fixes George Barrett via Gdb-patches
2021-07-29 16:53 ` Simon Marchi via Gdb-patches [this message]
2021-07-29 17:01   ` [PATCH v3 1/3] gdbtypes: return value from get_unsigned_type_max George Barrett via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=133a963e-2517-2ecb-2eeb-0df078a43f81@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=bob@bob131.so \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox