checkkconfigsymbols.py (762f99f4f3cb41a775b5157dd761217beba65873) checkkconfigsymbols.py (87c7ee67deb7fce9951a5f9d80641138694aad17)
1#!/usr/bin/env python3
2# SPDX-License-Identifier: GPL-2.0-only
3
4"""Find Kconfig symbols that are referenced but not defined."""
5
6# (c) 2014-2017 Valentin Rothberg <valentinrothberg@gmail.com>
7# (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
8#

--- 101 unchanged lines hidden (view full) ---

110 try:
111 re.match(args.ignore, "this/is/just/a/test.c")
112 except:
113 sys.exit("Please specify a valid Python regex.")
114
115 return args
116
117
1#!/usr/bin/env python3
2# SPDX-License-Identifier: GPL-2.0-only
3
4"""Find Kconfig symbols that are referenced but not defined."""
5
6# (c) 2014-2017 Valentin Rothberg <valentinrothberg@gmail.com>
7# (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
8#

--- 101 unchanged lines hidden (view full) ---

110 try:
111 re.match(args.ignore, "this/is/just/a/test.c")
112 except:
113 sys.exit("Please specify a valid Python regex.")
114
115 return args
116
117
118def main():
118def print_undefined_symbols():
119 """Main function of this module."""
120 args = parse_options()
121
122 global COLOR
123 COLOR = args.color and sys.stdout.isatty()
124
125 if args.sim and not args.commit and not args.diff:
126 sims = find_sims(args.sim, args.ignore)

--- 335 unchanged lines hidden (view full) ---

462 if REGEX_NUMERIC.match(symbol):
463 # ignore numeric values
464 continue
465 references.append(symbol)
466
467 return defined, references
468
469
119 """Main function of this module."""
120 args = parse_options()
121
122 global COLOR
123 COLOR = args.color and sys.stdout.isatty()
124
125 if args.sim and not args.commit and not args.diff:
126 sims = find_sims(args.sim, args.ignore)

--- 335 unchanged lines hidden (view full) ---

462 if REGEX_NUMERIC.match(symbol):
463 # ignore numeric values
464 continue
465 references.append(symbol)
466
467 return defined, references
468
469
470def main():
471 try:
472 print_undefined_symbols()
473 except BrokenPipeError:
474 # Python flushes standard streams on exit; redirect remaining output
475 # to devnull to avoid another BrokenPipeError at shutdown
476 devnull = os.open(os.devnull, os.O_WRONLY)
477 os.dup2(devnull, sys.stdout.fileno())
478 sys.exit(1) # Python exits with error code 1 on EPIPE
479
480
470if __name__ == "__main__":
471 main()
481if __name__ == "__main__":
482 main()