From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 8C06E3850211; Thu, 20 Oct 2022 15:45:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C06E3850211 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666280752; bh=JEpZMavI1UvMAq2KP0kTxD5VMFl9Jw25XU/Sqflh6P4=; h=From:To:Subject:Date:From; b=AZ64P5UU6rcJMsXp98pOOkCMj4doypbbv8cO+cAe8ngHATU52wVysyyIPnJVaAVkp h3sVdiAcQr7THzBSRLvxcM8/T2POAVLZn/C1SYdqHIjvQSEEMidcpSygB/dkp9sj/f oQapWdq3yrE68y2gmueO+N64LfEugKNfXpiellms= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: make use of scoped_restore in unduplicated_should_be_inserted X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 705b6305edc025c31606de16623a549697891193 X-Git-Newrev: aaa141a0a99fb63f6209da75257c58d94404a963 Message-Id: <20221020154552.8C06E3850211@sourceware.org> Date: Thu, 20 Oct 2022 15:45:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Daaa141a0a99f= b63f6209da75257c58d94404a963 commit aaa141a0a99fb63f6209da75257c58d94404a963 Author: Andrew Burgess Date: Wed Oct 5 10:21:02 2022 +0100 gdb: make use of scoped_restore in unduplicated_should_be_inserted =20 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. =20 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. =20 Approved-By: Simon Marchi 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. */ =20 -static int +static bool unduplicated_should_be_inserted (struct bp_location *bl) { - int result; - const int save_duplicate =3D bl->duplicate; + scoped_restore restore_bl_duplicate + =3D make_scoped_restore (&bl->duplicate, 0); =20 - bl->duplicate =3D 0; - result =3D should_be_inserted (bl); - bl->duplicate =3D save_duplicate; - return result; + return should_be_inserted (bl); } =20 /* Parses a conditional described by an expression COND into an