From: Heinrich Schuchardt <xypron.glpk@gmx.de>
Date: Sat, 9 Jan 2021 00:52:30 +0000 (+0100)
Subject: tools: efivar.py without arguments
X-Git-Tag: v2025.01-rc5-pxa1908~2066^2~14
X-Git-Url: http://git.dujemihanovic.xyz/posts?a=commitdiff_plain;h=4f6ec7754b1342ae9f9df4524fa9fa45299f3d68;p=u-boot.git

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
  File "tools/efivar.py", line 380, in <module>
    main()
  File "tools/efivar.py", line 360, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
---

diff --git a/tools/efivar.py b/tools/efivar.py
index ebfcab2f0a..c40a0fa6c7 100755
--- a/tools/efivar.py
+++ b/tools/efivar.py
@@ -357,7 +357,10 @@ def main():
     signp.set_defaults(func=cmd_sign)
 
     args = ap.parse_args()
-    args.func(args)
+    if hasattr(args, "func"):
+        args.func(args)
+    else:
+        ap.print_help()
 
 def group(a, *ns):
     for n in ns: