[Concept,13/14] buildman: Refactor _handle_command() to use single return

Message ID 20260110235633.1064859-14-sjg@u-boot.org
State New
Headers
Series buildman: Clean up pylint warnings in func_test |

Commit Message

Simon Glass Jan. 10, 2026, 11:56 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Refactor _handle_command() to assign results to a variable and return
at the end instead of having multiple return statements throughout.
This improves readability and makes the control flow clearer.

Also fix extra whitespace before 'size' and 'cpp' in endswith() calls.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 tools/buildman/func_test.py | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
  

Patch

diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 44ca2499b85..d784210446b 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -463,24 +463,23 @@  Idx Name          Size      VMA       LMA       File off  Algn
                 sys.exit(1)
         cmd = pipe_list[0][0]
         args = pipe_list[0][1:]
-        result = None
         if cmd == 'git':
             result = self._handle_command_git(args)
         elif cmd == './scripts/show-gnu-make':
-            return command.CommandResult(return_code=0, stdout='make')
+            result = command.CommandResult(return_code=0, stdout='make')
         elif cmd.endswith('nm'):
-            return self._handle_command_nm(args)
+            result = self._handle_command_nm(args)
         elif cmd.endswith('objdump'):
-            return self._handle_command_objdump(args)
+            result = self._handle_command_objdump(args)
         elif cmd.endswith('objcopy'):
-            return self._handle_command_objcopy(args)
-        elif cmd.endswith( 'size'):
-            return self._handle_command_size(args)
-        elif cmd.endswith( 'cpp'):
-            return self._handle_command_cpp(args)
+            result = self._handle_command_objcopy(args)
+        elif cmd.endswith('size'):
+            result = self._handle_command_size(args)
+        elif cmd.endswith('cpp'):
+            result = self._handle_command_cpp(args)
         elif cmd == 'gcc' and args[0] == '-E':
-            return self._handle_command_cpp(args[1:])
-        if not result:
+            result = self._handle_command_cpp(args[1:])
+        else:
             # Not handled, so abort
             print('unknown command', kwargs)
             sys.exit(1)