Skip to content

Commit e3a06a3

Browse files
committed
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.
1 parent f00fb12 commit e3a06a3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/lint/lint-locale-dependence.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
"src/test/fuzz/locale.cpp:.*setlocale",
5050
"src/test/fuzz/string.cpp:.*strtol",
5151
"src/test/fuzz/string.cpp:.*strtoul",
52-
"src/test/util_tests.cpp:.*strtoll"
52+
"src/test/util_tests.cpp:.*strtoll",
53+
"src/wallet/bdb.cpp:.*DbEnv::strerror", # False positive
54+
"src/util/syserror.cpp:.*strerror", # Outside this function use `SysErrorString`
5355
]
5456

5557
REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS = [
@@ -144,7 +146,7 @@
144146
"strcasecmp",
145147
"strcasestr",
146148
"strcoll", # LC_COLLATE
147-
#"strerror",
149+
"strerror",
148150
"strfmon",
149151
"strftime", # LC_TIME
150152
"strncasecmp",
@@ -218,7 +220,7 @@
218220
def find_locale_dependent_function_uses():
219221
regexp_locale_dependent_functions = "|".join(LOCALE_DEPENDENT_FUNCTIONS)
220222
exclude_args = [":(exclude)" + excl for excl in REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS]
221-
git_grep_command = ["git", "grep", "-E", "[^a-zA-Z0-9_\\`'\"<>](" + regexp_locale_dependent_functions + "(_r|_s)?)[^a-zA-Z0-9_\\`'\"<>]", "--", "*.cpp", "*.h"] + exclude_args
223+
git_grep_command = ["git", "grep", "-E", "[^a-zA-Z0-9_\\`'\"<>](" + regexp_locale_dependent_functions + ")(_r|_s)?[^a-zA-Z0-9_\\`'\"<>]", "--", "*.cpp", "*.h"] + exclude_args
222224
git_grep_output = list()
223225

224226
try:

0 commit comments

Comments
 (0)