Skip to content

[rtsan][NFC] Make Uninitialzed state explicit #109856

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 1 commit into from
Sep 24, 2024

Conversation

cjappl
Copy link
Contributor

@cjappl cjappl commented Sep 24, 2024

Follow on to #109830

There should be no functional change, as enums start at 0 anyway. This just makes the code more readable and prevents any future bugs.

@cjappl cjappl merged commit 38371a1 into llvm:main Sep 24, 2024
8 of 9 checks passed
@llvmbot
Copy link
Member

llvmbot commented Sep 24, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Chris Apple (cjappl)

Changes

Follow on to #109830

There should be no functional change, as enums start at 0 anyway. This just makes the code more readable and prevents any future bugs.


Full diff: https://github.com/llvm/llvm-project/pull/109856.diff

1 Files Affected:

  • (modified) compiler-rt/lib/rtsan/rtsan.cpp (+2-1)
diff --git a/compiler-rt/lib/rtsan/rtsan.cpp b/compiler-rt/lib/rtsan/rtsan.cpp
index e6d2481b2c2a3d..84e4b8fae1e2fa 100644
--- a/compiler-rt/lib/rtsan/rtsan.cpp
+++ b/compiler-rt/lib/rtsan/rtsan.cpp
@@ -31,7 +31,8 @@ enum class InitializationState : u8 {
 } // namespace
 
 static StaticSpinMutex rtsan_inited_mutex;
-static atomic_uint8_t rtsan_initialized = {0};
+static atomic_uint8_t rtsan_initialized = {
+    static_cast<u8>(InitializationState::Uninitialized)};
 
 static void SetInitializationState(InitializationState state) {
   atomic_store(&rtsan_initialized, static_cast<u8>(state),

@cjappl
Copy link
Contributor Author

cjappl commented Sep 24, 2024

CC @davidtrevelyan

@cjappl cjappl deleted the explicit_unitialized branch September 24, 2024 20:08
Copy link
Contributor

@fmayer fmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants