.. | .. |
---|
1 | 1 | #!/usr/bin/env python3 |
---|
| 2 | +# SPDX-License-Identifier: GPL-2.0-only |
---|
2 | 3 | |
---|
3 | 4 | """Find Kconfig symbols that are referenced but not defined.""" |
---|
4 | 5 | |
---|
5 | 6 | # (c) 2014-2017 Valentin Rothberg <valentinrothberg@gmail.com> |
---|
6 | 7 | # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> |
---|
7 | 8 | # |
---|
8 | | -# Licensed under the terms of the GNU GPL License version 2 |
---|
9 | 9 | |
---|
10 | 10 | |
---|
11 | 11 | import argparse |
---|
.. | .. |
---|
34 | 34 | REGEX_KCONFIG_DEF = re.compile(DEF) |
---|
35 | 35 | REGEX_KCONFIG_EXPR = re.compile(EXPR) |
---|
36 | 36 | 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*$") |
---|
38 | 38 | REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$") |
---|
39 | 39 | REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+") |
---|
40 | 40 | REGEX_QUOTES = re.compile("(\"(.*?)\")") |
---|
.. | .. |
---|
113 | 113 | return args |
---|
114 | 114 | |
---|
115 | 115 | |
---|
116 | | -def main(): |
---|
| 116 | +def print_undefined_symbols(): |
---|
117 | 117 | """Main function of this module.""" |
---|
118 | 118 | args = parse_options() |
---|
119 | 119 | |
---|
.. | .. |
---|
472 | 472 | return defined, references |
---|
473 | 473 | |
---|
474 | 474 | |
---|
| 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 | + |
---|
475 | 486 | if __name__ == "__main__": |
---|
476 | 487 | main() |
---|