mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
partial revert dash#4807: enable more multi-threading and caching in linters
reverts:
- 3e6385eaa8
(only `run-lint-format-strings.py`)
This commit is contained in:
parent
7864c21645
commit
a0b051b4ef
@ -11,8 +11,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from functools import partial
|
|
||||||
from multiprocessing import Pool
|
|
||||||
|
|
||||||
FALSE_POSITIVES = [
|
FALSE_POSITIVES = [
|
||||||
("src/batchedlogger.h", "strprintf(fmt, args...)"),
|
("src/batchedlogger.h", "strprintf(fmt, args...)"),
|
||||||
@ -265,8 +263,17 @@ def count_format_specifiers(format_string):
|
|||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
||||||
def handle_filename(filename, args):
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="This program checks that the number of arguments passed "
|
||||||
|
"to a variadic format string function matches the number of format "
|
||||||
|
"specifiers in the format string.")
|
||||||
|
parser.add_argument("--skip-arguments", type=int, help="number of arguments before the format string "
|
||||||
|
"argument (e.g. 1 in the case of fprintf)", default=0)
|
||||||
|
parser.add_argument("function_name", help="function name (e.g. fprintf)", default=None)
|
||||||
|
parser.add_argument("file", nargs="*", help="C++ source code file (e.g. foo.cpp)")
|
||||||
|
args = parser.parse_args()
|
||||||
exit_code = 0
|
exit_code = 0
|
||||||
|
for filename in args.file:
|
||||||
with open(filename, "r", encoding="utf-8") as f:
|
with open(filename, "r", encoding="utf-8") as f:
|
||||||
for function_call_str in parse_function_calls(args.function_name, f.read()):
|
for function_call_str in parse_function_calls(args.function_name, f.read()):
|
||||||
parts = parse_function_call_and_arguments(args.function_name, function_call_str)
|
parts = parse_function_call_and_arguments(args.function_name, function_call_str)
|
||||||
@ -284,24 +291,7 @@ def handle_filename(filename, args):
|
|||||||
exit_code = 1
|
exit_code = 1
|
||||||
print("{}: Expected {} argument(s) after format string but found {} argument(s): {}".format(f.name, format_specifier_count, argument_count, relevant_function_call_str))
|
print("{}: Expected {} argument(s) after format string but found {} argument(s): {}".format(f.name, format_specifier_count, argument_count, relevant_function_call_str))
|
||||||
continue
|
continue
|
||||||
return exit_code
|
sys.exit(exit_code)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description="This program checks that the number of arguments passed "
|
|
||||||
"to a variadic format string function matches the number of format "
|
|
||||||
"specifiers in the format string.")
|
|
||||||
parser.add_argument("--skip-arguments", type=int, help="number of arguments before the format string "
|
|
||||||
"argument (e.g. 1 in the case of fprintf)", default=0)
|
|
||||||
parser.add_argument("function_name", help="function name (e.g. fprintf)", default=None)
|
|
||||||
parser.add_argument("file", nargs="*", help="C++ source code file (e.g. foo.cpp)")
|
|
||||||
args = parser.parse_args()
|
|
||||||
exit_codes = []
|
|
||||||
|
|
||||||
with Pool(8) as pool:
|
|
||||||
exit_codes = pool.map(partial(handle_filename, args=args), args.file)
|
|
||||||
|
|
||||||
sys.exit(max(exit_codes))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user