From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCHv2 3/4] gdb: make use of scoped_restore in unduplicated_should_be_inserted
Date: Wed, 19 Oct 2022 14:07:09 +0100 [thread overview]
Message-ID: <09c9b60cfe15b3a8d47fd135a391ece82909eeb7.1666184729.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1666184729.git.aburgess@redhat.com>
I noticed that we could make use of a scoped_restore in the function
unduplicated_should_be_inserted. I've also converted the function
return type from int to bool.
This change shouldn't make any difference, as I don't think anything
within should_be_inserted could throw an exception, but the change
doesn't hurt, and will help keep us safe if anything ever changes in
the future.
---
gdb/breakpoint.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 3ddf025acca..7e2b804156f 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2299,16 +2299,13 @@ should_be_inserted (struct bp_location *bl)
/* Same as should_be_inserted but does the check assuming
that the location is not duplicated. */
-static int
+static bool
unduplicated_should_be_inserted (struct bp_location *bl)
{
- int result;
- const int save_duplicate = bl->duplicate;
+ scoped_restore restore_bl_duplicate
+ = make_scoped_restore (&bl->duplicate, 0);
- bl->duplicate = 0;
- result = should_be_inserted (bl);
- bl->duplicate = save_duplicate;
- return result;
+ return should_be_inserted (bl);
}
/* Parses a conditional described by an expression COND into an
--
2.25.4
next prev parent reply other threads:[~2022-10-19 13:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 9:32 [PATCH 0/4] Const args, int->bool, and scoped_restore in breakpoint.c Andrew Burgess
2022-10-05 9:32 ` [PATCH 1/4] gdb: make some bp_location arguments const " Andrew Burgess
2022-10-18 13:46 ` Bruno Larsen
2022-10-05 9:32 ` [PATCH 2/4] gdb: used scoped_restore_frame in update_watchpoint Andrew Burgess
2022-10-05 9:32 ` [PATCH 3/4] gdb: make use of scoped_restore in unduplicated_should_be_inserted Andrew Burgess
2022-10-05 9:32 ` [PATCH 4/4] gdb: some int to bool conversion in breakpoint.c Andrew Burgess
2022-10-19 13:07 ` [PATCHv2 0/4] Const args, int->bool, and scoped_restore " Andrew Burgess
2022-10-19 13:07 ` [PATCHv2 1/4] gdb: make some bp_location arguments const " Andrew Burgess
2022-10-19 13:07 ` [PATCHv2 2/4] gdb: used scoped_restore_frame in update_watchpoint Andrew Burgess
2022-10-19 13:07 ` Andrew Burgess [this message]
2022-10-19 13:07 ` [PATCHv2 4/4] gdb: some int to bool conversion in breakpoint.c Andrew Burgess
2022-10-19 20:03 ` Simon Marchi
2022-10-20 15:48 ` Andrew Burgess
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=09c9b60cfe15b3a8d47fd135a391ece82909eeb7.1666184729.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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).