hc
2024-02-19 151fecfb72a0d602dfe79790602ef64b4e241574
kernel/scripts/checkkconfigsymbols.py
....@@ -1,11 +1,11 @@
11 #!/usr/bin/env python3
2
+# SPDX-License-Identifier: GPL-2.0-only
23
34 """Find Kconfig symbols that are referenced but not defined."""
45
56 # (c) 2014-2017 Valentin Rothberg <valentinrothberg@gmail.com>
67 # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
78 #
8
-# Licensed under the terms of the GNU GPL License version 2
99
1010
1111 import argparse
....@@ -34,7 +34,7 @@
3434 REGEX_KCONFIG_DEF = re.compile(DEF)
3535 REGEX_KCONFIG_EXPR = re.compile(EXPR)
3636 REGEX_KCONFIG_STMT = re.compile(STMT)
37
-REGEX_KCONFIG_HELP = re.compile(r"^\s+(help|---help---)\s*$")
37
+REGEX_KCONFIG_HELP = re.compile(r"^\s+help\s*$")
3838 REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$")
3939 REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+")
4040 REGEX_QUOTES = re.compile("(\"(.*?)\")")
....@@ -113,7 +113,7 @@
113113 return args
114114
115115
116
-def main():
116
+def print_undefined_symbols():
117117 """Main function of this module."""
118118 args = parse_options()
119119
....@@ -472,5 +472,16 @@
472472 return defined, references
473473
474474
475
+def main():
476
+ try:
477
+ print_undefined_symbols()
478
+ except BrokenPipeError:
479
+ # Python flushes standard streams on exit; redirect remaining output
480
+ # to devnull to avoid another BrokenPipeError at shutdown
481
+ devnull = os.open(os.devnull, os.O_WRONLY)
482
+ os.dup2(devnull, sys.stdout.fileno())
483
+ sys.exit(1) # Python exits with error code 1 on EPIPE
484
+
485
+
475486 if __name__ == "__main__":
476487 main()