public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: make use of scoped_restore in unduplicated_should_be_inserted
@ 2022-10-20 15:45 Andrew Burgess
0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2022-10-20 15:45 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aaa141a0a99fb63f6209da75257c58d94404a963
commit aaa141a0a99fb63f6209da75257c58d94404a963
Author: Andrew Burgess <aburgess@redhat.com>
Date: Wed Oct 5 10:21:02 2022 +0100
gdb: make use of scoped_restore in unduplicated_should_be_inserted
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.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diff:
---
gdb/breakpoint.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 84eeccd0cd7..bfa017f1398 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-20 15:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 15:45 [binutils-gdb] gdb: make use of scoped_restore in unduplicated_should_be_inserted Andrew Burgess
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).