* [PATCH] Remove dead code from windows_nat_target::detach
@ 2022-07-22 18:56 Tom Tromey
2022-07-22 19:27 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2022-07-22 18:56 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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 ();
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Remove dead code from windows_nat_target::detach
2022-07-22 18:56 [PATCH] Remove dead code from windows_nat_target::detach Tom Tromey
@ 2022-07-22 19:27 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2022-07-22 19:27 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-22 19:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 18:56 [PATCH] Remove dead code from windows_nat_target::detach Tom Tromey
2022-07-22 19:27 ` Simon Marchi
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).