Skip to content

[clang-tidy] Do not flag strerror in concurrency-mt-unsafe #140520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ static const clang::StringRef GlibcFunctions[] = {
"::sigsuspend",
"::sleep",
"::srand48",
"::strerror",
"::strsignal",
"::strtok",
"::tcflow",
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ Changes in existing checks
<clang-tidy/checks/cert/err33-c>` check by fixing false positives when
a function name is just prefixed with a targeted function name.

- Improved :doc:`concurrency-mt-unsafe
<clang-tidy/checks/concurrency/mt-unsafe>` check by fixing a false positive
where ``strerror`` was flagged as MT-unsafe.

- Improved :doc:`misc-const-correctness
<clang-tidy/checks/misc/const-correctness>` check by adding the option
`AllowedTypes`, that excludes specified types from const-correctness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
extern unsigned int sleep (unsigned int __seconds);
extern int *gmtime (const int *__timer);
extern char *dirname (char *__path);
extern char *strerror(int errnum);

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

dirname(nullptr);

strerror(0);
}
Loading