From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6D6D73858405 for ; Fri, 22 Jul 2022 19:27:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D6D73858405 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 221D71E222; Fri, 22 Jul 2022 15:27:50 -0400 (EDT) Message-ID: Date: Fri, 22 Jul 2022 15:27:49 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] Remove dead code from windows_nat_target::detach Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20220722185641.4053809-1-tromey@adacore.com> From: Simon Marchi In-Reply-To: <20220722185641.4053809-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, 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 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: Fri, 22 Jul 2022 19:27:51 -0000 On 2022-07-22 14:56, Tom Tromey via Gdb-patches wrote: > windows_nat_target::detach has a variable 'detached' that is only set > after a call to 'error'. However, this can't happen because 'error' > throws an exception. > > This patch removes the dead code. > --- > gdb/windows-nat.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c > index 43a2c112db5..9265ed9e632 100644 > --- a/gdb/windows-nat.c > +++ b/gdb/windows-nat.c > @@ -1912,22 +1912,16 @@ windows_nat_target::attach (const char *args, int from_tty) > void > windows_nat_target::detach (inferior *inf, int from_tty) > { > - int detached = 1; > - > ptid_t ptid = minus_one_ptid; > resume (ptid, 0, GDB_SIGNAL_0); > > if (!DebugActiveProcessStop (windows_process.current_event.dwProcessId)) > - { > - error (_("Can't detach process %u (error %u)"), > - (unsigned) windows_process.current_event.dwProcessId, > - (unsigned) GetLastError ()); > - detached = 0; > - } > + error (_("Can't detach process %u (error %u)"), > + (unsigned) windows_process.current_event.dwProcessId, > + (unsigned) GetLastError ()); > DebugSetProcessKillOnExit (FALSE); > > - if (detached) > - target_announce_detach (from_tty); > + target_announce_detach (from_tty); > > x86_cleanup_dregs (); > switch_to_no_thread (); LGTM. Simon