public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/4] Use gdb::checked_static_cast for watchpoints
Date: Sun, 17 Sep 2023 20:40:33 -0400	[thread overview]
Message-ID: <1aba9929-690e-448d-b7d7-5cf90604fdad@polymtl.ca> (raw)
In-Reply-To: <20230915-watchpoint-casts-v1-1-a4ff35c9644e@adacore.com>



On 2023-09-15 14:36, Tom Tromey via Gdb-patches wrote:
> This replaces some casts to 'watchpoint *' with checked_static_cast.
> In one spot, an unnecessary block is also removed.
> ---
>  gdb/breakpoint.c           | 298 +++++++++++++++++++++++----------------------
>  gdb/guile/scm-breakpoint.c |   2 +-
>  gdb/python/py-breakpoint.c |   2 +-
>  3 files changed, 153 insertions(+), 149 deletions(-)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index c429af455ff..c0d86f38c73 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -5249,7 +5249,7 @@ watchpoint_check (bpstat *bs)
>  
>    /* BS is built from an existing struct breakpoint.  */
>    gdb_assert (bs->breakpoint_at != NULL);
> -  b = (struct watchpoint *) bs->breakpoint_at;
> +  b = gdb::checked_static_cast<struct watchpoint *> (bs->breakpoint_at);

Not mandatory, but when doing these refactorings, I find it's a good
time to bring the variable declaration down.  And also, get rid of the
struct keyword, if possible.  So:

  watchpoint *b = gdb::checked_static_cast<watchpoint *> (bs->breakpoint_at);

Simon

  reply	other threads:[~2023-09-18  0:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 18:36 [PATCH 0/4] Use checked_static_cast for breakpoint casts Tom Tromey
2023-09-15 18:36 ` [PATCH 1/4] Use gdb::checked_static_cast for watchpoints Tom Tromey
2023-09-18  0:40   ` Simon Marchi [this message]
2023-09-18 14:20     ` Tom Tromey
2023-09-15 18:36 ` [PATCH 2/4] Use gdb::checked_static_cast for tracepoints Tom Tromey
2023-09-15 18:36 ` [PATCH 3/4] Use gdb::checked_static_cast for code_breakpoint Tom Tromey
2023-09-15 18:36 ` [PATCH 4/4] Use gdb::checked_static_cast for catchpoints Tom Tromey
2023-09-18  0:45 ` [PATCH 0/4] Use checked_static_cast for breakpoint casts Simon Marchi

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=1aba9929-690e-448d-b7d7-5cf90604fdad@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).