From 520a6644a65fe9255a71dd8cec00b31495e523c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jun 2023 14:44:05 +0200 Subject: [PATCH] y2038.py: some fixes for obsolete code in y2038.py (#5131) --- addons/y2038.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/addons/y2038.py b/addons/y2038.py index 51e06e1f2..2c3856c5d 100755 --- a/addons/y2038.py +++ b/addons/y2038.py @@ -9,10 +9,9 @@ # 3. Any Y2038-unsafe symbol when _USE_TIME_BITS64 is not defined. # # Example usage: -# $ cppcheck --dump path-to-src/test.c -# $ y2038.py path-to-src/test.c.dump +# $ cppcheck --addon=y2038 path-to-src/test.c # -# y2038.py will walk the source tree for .dump files. + from __future__ import print_function import cppcheckdata @@ -156,22 +155,14 @@ def check_y2038_safe(dumpfile, quiet=False): # load XML from .dump file data = cppcheckdata.CppcheckData(dumpfile) - # Convert dump file path to source file in format generated by cppcheck. - # For example after the following call: - # cppcheck ./src/my-src.c --dump - # We got 'src/my-src.c' value for 'file' field in cppcheckdata. - srcfile = dumpfile.rstrip('.dump') - srcfile = os.path.expanduser(srcfile) - srcfile = os.path.normpath(srcfile) - - # go through each configuration + srcfile = data.files[0] for cfg in data.iterconfigurations(): if not quiet: print('Checking %s, config %s...' % (srcfile, cfg.name)) safe_ranges = [] safe = -1 time_bits_defined = False - srclinenr = '0' + srclinenr = 0 for directive in cfg.directives: # track source line number @@ -236,7 +227,7 @@ if __name__ == '__main__': args = parser.parse_args() exit_code = 0 - quiet = not any((args.quiet, args.cli)) + quiet = args.quiet or args.cli if not args.dumpfile: if not args.quiet: @@ -244,7 +235,7 @@ if __name__ == '__main__': sys.exit(0) for dumpfile in args.dumpfile: - if not args.quiet: + if not quiet: print('Checking ' + dumpfile + '...') check_y2038_safe(dumpfile, quiet)