From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 23BAA3858291 for ; Wed, 19 Oct 2022 13:07:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 23BAA3858291 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-297--sz4bUEwNYmgeKKZU7Ghjg-1; Wed, 19 Oct 2022 09:07:22 -0400 X-MC-Unique: -sz4bUEwNYmgeKKZU7Ghjg-1 Received: by mail-qt1-f197.google.com with SMTP id cc18-20020a05622a411200b0039cdeb3a699so8563063qtb.23 for ; Wed, 19 Oct 2022 06:07:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LO0IJfHZlGxB8b3MjvdFNBh6ThQ2NBc8pMrsknGIKSk=; b=xiaGdVdqbXLDjjs/Azzsgcm2+SP1C9/2B935ISEvXjFG3W9LLQpO4GA/Bs6TyfuKgV gWHtCBKLxcFQiHLpFGDaD4P3s5cwUej9CtlZKfcsxh3+8MXx9SPnRHzOn+BbFXSqIUDA /juWvtPTOcDKofNKbktaCyMMXZ/m+rGaRpCNW+yArleU17XPrqHXmpXe2l620i2oAsqk 6k6HtqMuPpZzqhMgWWvI/oMizdKpuVxJcCMHQbfZGQCbIsZDBI6gjXYUhFax+CZ1OO+h NdIVy8kHexvqiQqrIK8vvCI7EVvmP4L5LCPdq2rKULsqXaSioT/petphagxZr2stXHe7 apFg== X-Gm-Message-State: ACrzQf2oehgLRSIWO8/Kj5UPl+mcVV2qvl2XlEaVZrux8EBkrXlJ9K5u 1m2zUhkVCXWsBMar/xxWpXCv0eSiD2vIk47+smZlSE6QcMB4eKr8nfowlq+zZN1mPmuCbsRjKU/ MWzk1vwl340+kOq5Fg6qlD0BRfXuIwz1k937dM3vhEd1l7P8euz99hhmJHFPF+xLjIF04M53omA == X-Received: by 2002:a05:620a:24c9:b0:6ee:d791:9f84 with SMTP id m9-20020a05620a24c900b006eed7919f84mr5502540qkn.490.1666184841631; Wed, 19 Oct 2022 06:07:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hOC4EqfoGEbP4n3ye5yLIH5AlMw6w9/b9UvAzs6cjb07ocqFSMzFEHjPQ11TQs5re19v1yg== X-Received: by 2002:a05:620a:24c9:b0:6ee:d791:9f84 with SMTP id m9-20020a05620a24c900b006eed7919f84mr5502504qkn.490.1666184841201; Wed, 19 Oct 2022 06:07:21 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id fd4-20020a05622a4d0400b0039cd508f1d3sm4021906qtb.75.2022.10.19.06.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 06:07:21 -0700 (PDT) From: Andrew Burgess 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 Message-Id: <09c9b60cfe15b3a8d47fd135a391ece82909eeb7.1666184729.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2022 13:07:32 -0000 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