Skip to content

Commit 322d019

Browse files
carlosgalvezpCarlos GálvezEugeneZelenko
authored
[clang-tidy] Do not flag strerror in concurrency-mt-unsafe (llvm#140520)
The docs of the check state: > Glibc’s list is compiled from GNU web documentation with a search for MT-Safe tag And strerror fulfills exactly that: https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html > Function: char * strerror (int errnum) > Preliminary: | MT-Safe | AS-Unsafe heap i18n | AC-Unsafe mem | See POSIX Safety Concepts. So concurrency-mt-unsafe should not flag it. Fixes llvm#140515 --------- Co-authored-by: Carlos Gálvez <[email protected]> Co-authored-by: EugeneZelenko <[email protected]>
1 parent 29fd767 commit 322d019

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static const clang::StringRef GlibcFunctions[] = {
153153
"::sigsuspend",
154154
"::sleep",
155155
"::srand48",
156-
"::strerror",
157156
"::strsignal",
158157
"::strtok",
159158
"::tcflow",

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ Changes in existing checks
172172
<clang-tidy/checks/cert/err33-c>` check by fixing false positives when
173173
a function name is just prefixed with a targeted function name.
174174

175+
- Improved :doc:`concurrency-mt-unsafe
176+
<clang-tidy/checks/concurrency/mt-unsafe>` check by fixing a false positive
177+
where ``strerror`` was flagged as MT-unsafe.
178+
175179
- Improved :doc:`misc-const-correctness
176180
<clang-tidy/checks/misc/const-correctness>` check by adding the option
177181
`AllowedTypes`, that excludes specified types from const-correctness

clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
extern unsigned int sleep (unsigned int __seconds);
44
extern int *gmtime (const int *__timer);
55
extern char *dirname (char *__path);
6+
extern char *strerror(int errnum);
67

78
void foo() {
89
sleep(2);
@@ -12,4 +13,6 @@ void foo() {
1213
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
1314

1415
dirname(nullptr);
16+
17+
strerror(0);
1518
}

0 commit comments

Comments
 (0)