Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/tui] Simplify tui_enable
@ 2026-04-29 11:28 Tom de Vries
  2026-05-01 16:38 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-04-29 11:28 UTC (permalink / raw)
  To: gdb-patches

I noticed some code in tui_enable doing:
...
if (...)
  error (...);
else if (...)
...
which is the "Don’t use else after a return" anti-pattern [1].

Fix this by using:
...
if (...)
  error (...);

if (...)
...

[1] https://llvm.org/docs/CodingStandards.html#id41
---
 gdb/tui/tui.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index ba4f6f68769..de2faa36af7 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -429,7 +429,8 @@ tui_enable (void)
 	 again.  */
       error (_("Cannot enable the TUI"));
     }
-  else if (tui_finish_init == TRIBOOL_TRUE)
+
+  if (tui_finish_init == TRIBOOL_TRUE)
     {
       WINDOW *w;
       SCREEN *s;

base-commit: 8a5e138e6276ce7644ab858751440cb59f35623b
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [gdb/tui] Simplify tui_enable
  2026-04-29 11:28 [PATCH] [gdb/tui] Simplify tui_enable Tom de Vries
@ 2026-05-01 16:38 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2026-05-01 16:38 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> I noticed some code in tui_enable doing:
Tom> ...
Tom> if (...)
Tom>   error (...);
Tom> else if (...)
Tom> ...
Tom> which is the "Don’t use else after a return" anti-pattern [1].

Ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-01 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-29 11:28 [PATCH] [gdb/tui] Simplify tui_enable Tom de Vries
2026-05-01 16:38 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox