[libc-commits] [libc] [libc][mutex] add error checking support (PR #197035)

via libc-commits libc-commits at lists.llvm.org
Tue May 12 21:44:32 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- libc/include/llvm-libc-macros/pthread-macros.h libc/include/llvm-libc-types/__mutex_type.h libc/src/__support/threads/mutex.h libc/src/__support/threads/mutex_common.h libc/src/__support/threads/unix_mutex.h libc/src/pthread/pthread_mutex_init.cpp libc/src/pthread/pthread_mutex_lock.cpp libc/src/pthread/pthread_mutex_trylock.cpp libc/src/pthread/pthread_mutex_unlock.cpp libc/test/integration/src/pthread/pthread_mutex_test.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/__support/threads/unix_mutex.h b/libc/src/__support/threads/unix_mutex.h
index 9306ec48e..272a1dfe6 100644
--- a/libc/src/__support/threads/unix_mutex.h
+++ b/libc/src/__support/threads/unix_mutex.h
@@ -47,8 +47,7 @@ class Mutex final : private RawMutex {
         return MutexError::OVERFLOW;
       lock_count++;
       return MutexError::NONE;
-    }
-    else if (is_error_checking() && owner == internal::gettid())
+    } else if (is_error_checking() && owner == internal::gettid())
       return MutexError::DEADLOCK;
 
     MutexError res = do_lock();

``````````

</details>


https://github.com/llvm/llvm-project/pull/197035


More information about the libc-commits mailing list