projects
/
kconfig-hardened-check.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
822d781
)
Precise the Kconfig parsing
author
Alexander Popov
<alex.popov@linux.com>
Sat, 15 Jul 2023 19:58:17 +0000
(22:58 +0300)
committer
Alexander Popov
<alex.popov@linux.com>
Sat, 15 Jul 2023 21:24:26 +0000
(
00:24
+0300)
kconfig_hardened_check/__init__.py
patch
|
blob
|
history
diff --git
a/kconfig_hardened_check/__init__.py
b/kconfig_hardened_check/__init__.py
index 832f241c40b7d2df50af1e20c6b06cdee08935ff..1b6cc2e9acc30bb2e587b2d3fa820bf152839326 100644
(file)
--- a/
kconfig_hardened_check/__init__.py
+++ b/
kconfig_hardened_check/__init__.py
@@
-152,8
+152,8
@@
def print_checklist(mode, checklist, with_results):
def parse_kconfig_file(parsed_options, fname):
with _open(fname, 'rt', encoding='utf-8') as f:
def parse_kconfig_file(parsed_options, fname):
with _open(fname, 'rt', encoding='utf-8') as f:
- opt_is_on = re.compile("CONFIG_[a-zA-Z0-9_]
*=[a-zA-Z0-9_\"]*
")
- opt_is_off = re.compile("# CONFIG_[a-zA-Z0-9_]
* is not set
")
+ opt_is_on = re.compile("CONFIG_[a-zA-Z0-9_]
+=.+$
")
+ opt_is_off = re.compile("# CONFIG_[a-zA-Z0-9_]
+ is not set$
")
for line in f.readlines():
line = line.strip()
for line in f.readlines():
line = line.strip()
@@
-166,8
+166,10
@@
def parse_kconfig_file(parsed_options, fname):
sys.exit(f'[!] ERROR: bad enabled Kconfig option "{line}"')
elif opt_is_off.match(line):
option, value = line[2:].split(' ', 1)
sys.exit(f'[!] ERROR: bad enabled Kconfig option "{line}"')
elif opt_is_off.match(line):
option, value = line[2:].split(' ', 1)
- if value != 'is not set':
- sys.exit(f'[!] ERROR: bad disabled Kconfig option "{line}"')
+ assert(value == 'is not set'), \
+ f'unexpected value of disabled Kconfig option "{line}"'
+ elif line != '' and not line.startswith('#'):
+ print(f'[!] WARNING: strange line in Kconfig file: "{line}"')
if option in parsed_options:
sys.exit(f'[!] ERROR: Kconfig option "{line}" exists multiple times')
if option in parsed_options:
sys.exit(f'[!] ERROR: Kconfig option "{line}" exists multiple times')