From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 140403858D32 for ; Mon, 18 Sep 2023 00:40:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 140403858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 38I0eYeL005701 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 17 Sep 2023 20:40:39 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 38I0eYeL005701 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1694997639; bh=GGx3Jb6uJ83pItCaU9kTxUCjviVuZWgP8cDo0/QQdSU=; h=Date:Subject:To:References:From:In-Reply-To:From; b=G7tFyd0cZcayWbmq94I954XJFreuYqsXDYnvrtCYdqiY4oggMYHb9rK8WEpEwzW/V khtA7ub1IVFj0SpSmayvg0eYKWaOUS4SPXgseZNSq1iXgTrhI859TD0cY6XTH1bCs0 7Fr1592hcE6bkPdhZ+Q2e6qiD5JZbCrKt3+fCl44= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id E3A691E092; Sun, 17 Sep 2023 20:40:33 -0400 (EDT) Message-ID: <1aba9929-690e-448d-b7d7-5cf90604fdad@polymtl.ca> Date: Sun, 17 Sep 2023 20:40:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] Use gdb::checked_static_cast for watchpoints Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20230915-watchpoint-casts-v1-0-a4ff35c9644e@adacore.com> <20230915-watchpoint-casts-v1-1-a4ff35c9644e@adacore.com> From: Simon Marchi In-Reply-To: <20230915-watchpoint-casts-v1-1-a4ff35c9644e@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 18 Sep 2023 00:40:34 +0000 X-Spam-Status: No, score=-3037.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,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 List-Id: 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 (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 (bs->breakpoint_at); Simon