aboutsummaryrefslogtreecommitdiff
path: root/test/lint
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2022-04-28 09:55:45 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2022-04-28 10:24:06 +0200
commite3a06a3c6cbb288ac89a2725cf71ae8adaebf35c (patch)
treeea33a9070e07b1358856c7138e797d86b761f8a4 /test/lint
parentf00fb1265a8bc26e1612c771173325dbe49b3612 (diff)
downloadbitcoin-e3a06a3c6cbb288ac89a2725cf71ae8adaebf35c.tar.xz
test: Add `strerror` to locale-dependence linter
Add `strerror` to the locale-dependence linter to catch its use. Add exemptions for bdb interface code (false positive) and strerror.cpp (the only allowed use). Also fix a bug in the regexp so that `_r` and `_s` variants are detected again.
Diffstat (limited to 'test/lint')
-rwxr-xr-xtest/lint/lint-locale-dependence.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/lint/lint-locale-dependence.py b/test/lint/lint-locale-dependence.py
index 2abf1be6b3..9b2cf4587a 100755
--- a/test/lint/lint-locale-dependence.py
+++ b/test/lint/lint-locale-dependence.py
@@ -49,7 +49,9 @@ KNOWN_VIOLATIONS = [
"src/test/fuzz/locale.cpp:.*setlocale",
"src/test/fuzz/string.cpp:.*strtol",
"src/test/fuzz/string.cpp:.*strtoul",
- "src/test/util_tests.cpp:.*strtoll"
+ "src/test/util_tests.cpp:.*strtoll",
+ "src/wallet/bdb.cpp:.*DbEnv::strerror", # False positive
+ "src/util/syserror.cpp:.*strerror", # Outside this function use `SysErrorString`
]
REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS = [
@@ -144,7 +146,7 @@ LOCALE_DEPENDENT_FUNCTIONS = [
"strcasecmp",
"strcasestr",
"strcoll", # LC_COLLATE
- #"strerror",
+ "strerror",
"strfmon",
"strftime", # LC_TIME
"strncasecmp",
@@ -218,7 +220,7 @@ LOCALE_DEPENDENT_FUNCTIONS = [
def find_locale_dependent_function_uses():
regexp_locale_dependent_functions = "|".join(LOCALE_DEPENDENT_FUNCTIONS)
exclude_args = [":(exclude)" + excl for excl in REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS]
- git_grep_command = ["git", "grep", "-E", "[^a-zA-Z0-9_\\`'\"<>](" + regexp_locale_dependent_functions + "(_r|_s)?)[^a-zA-Z0-9_\\`'\"<>]", "--", "*.cpp", "*.h"] + exclude_args
+ git_grep_command = ["git", "grep", "-E", "[^a-zA-Z0-9_\\`'\"<>](" + regexp_locale_dependent_functions + ")(_r|_s)?[^a-zA-Z0-9_\\`'\"<>]", "--", "*.cpp", "*.h"] + exclude_args
git_grep_output = list()
try: