Clearer code to search for config.h
Don't use a function argument as a for loop variable. It worked (mostly) but
Pylint frowns on it (redefined-argument-from-local) and I think Pylint has a
point.
If the configuration file is not found, raise an exception mentioning the
search path rather than just its last element.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/scripts/config.py b/scripts/config.py
index b7a9a08..d6eb2e4 100755
--- a/scripts/config.py
+++ b/scripts/config.py
@@ -283,9 +283,13 @@
def __init__(self, filename=None):
"""Read the Mbed TLS configuration file."""
if filename is None:
- for filename in self.default_path:
- if os.path.lexists(filename):
+ for candidate in self.default_path:
+ if os.path.lexists(candidate):
+ filename = candidate
break
+ else:
+ raise Exception('Mbed TLS configuration file not found',
+ self.default_path)
super().__init__()
self.filename = filename
self.current_section = 'header'