[6/9] isar-sstate: fix failures if a variable is set to just whitespace

Message ID 20240405163135.2987489-7-chris.larson@siemens.com
State Accepted, archived
Headers show
Series Add more signature cachability tests to the testsuite | expand

Commit Message

Larson, Chris April 5, 2024, 4:31 p.m. UTC
From: Christopher Larson <chris.larson@siemens.com>

We see this failure if a variable is set to the empty string, as whitespace is
being stripped off of the variable after we check if the value is empty or None,
not before.

    Traceback (most recent call last):
    File "/home/kergoth/Code/indos/signatures/isar/scripts/isar-sstate", line 941, in <module>
        sys.exit(main())
                ^^^^^^
    File "/home/kergoth/Code/indos/signatures/isar/scripts/isar-sstate", line 937, in main
        return globals()[f'sstate_{args.command}'](**vars(args))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/kergoth/Code/indos/signatures/isar/scripts/isar-sstate", line 894, in sstate_lint
        if not val[0] == '/':
            ~~~^^^
    IndexError: string index out of range

Signed-off-by: Christopher Larson <chris.larson@siemens.com>
---
 scripts/isar-sstate | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/scripts/isar-sstate b/scripts/isar-sstate
index a4429b7a..4ea38bc8 100755
--- a/scripts/isar-sstate
+++ b/scripts/isar-sstate
@@ -868,10 +868,11 @@  def sstate_lint(target, verbose, sources_dir, build_dir, exit_code, pedantic, li
                sigdata['taskhash_ignore_tasks'] and name in sigdata['taskhash_ignore_tasks'] or \
                name in ADDITIONAL_IGNORED_VARNAMES:
                 continue
-            if not val:
-                continue
             # remove leading whitespaces possibly added by appending
             val = val.lstrip()
+            if not val:
+                continue
+
             if name == 'SRC_URI':
                 src_uri = val.split()
                 for entry in src_uri: