[binutils-gdb] [gdb/tui] Simplify tui_enable

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dfbb704fa390c789c66c99f000ea0cdfdb8aab1c

commit dfbb704fa390c789c66c99f000ea0cdfdb8aab1c
Author: Tom de Vries <[email protected]>
Date:   Fri May 1 18:46:09 2026 +0200

    [gdb/tui] Simplify tui_enable
    
    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 (...)
    ...
    
    Approved-By: Tom Tromey <[email protected]>
    
    [1] https://llvm.org/docs/CodingStandards.html#id41

Diff:
---
 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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.