[libc-commits] [PATCH] D124468: [libc] Minor test signedness fixes

Dominic Chen via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Apr 26 10:27:02 PDT 2022


ddcc created this revision.
ddcc added reviewers: sivachandra, lntue.
Herald added subscribers: ecnelises, tschuett.
Herald added projects: libc-project, All.
ddcc requested review of this revision.

Resolve compiler warnings about signed conversion


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124468

Files:
  libc/test/src/threads/cnd_test.cpp
  libc/utils/testutils/ExecuteFunction.h


Index: libc/utils/testutils/ExecuteFunction.h
===================================================================
--- libc/utils/testutils/ExecuteFunction.h
+++ libc/utils/testutils/ExecuteFunction.h
@@ -24,7 +24,7 @@
   int platform_defined;
   const char *failure = nullptr;
 
-  static constexpr uintptr_t TIMEOUT = -1L;
+  static constexpr uintptr_t TIMEOUT = ~0UL;
 
   static ProcessStatus error(const char *error) { return {0, error}; }
   static ProcessStatus timed_out_ps() {
@@ -41,7 +41,7 @@
 };
 
 ProcessStatus invoke_in_subprocess(FunctionCaller *func,
-                                   unsigned timeout_ms = -1);
+                                   unsigned timeout_ms = ~0U);
 
 const char *signal_as_string(int signum);
 
Index: libc/test/src/threads/cnd_test.cpp
===================================================================
--- libc/test/src/threads/cnd_test.cpp
+++ libc/test/src/threads/cnd_test.cpp
@@ -41,7 +41,7 @@
 
 int broadcast_thread_func(void *) {
   __llvm_libc::mtx_lock(&broadcast_mtx);
-  int oldval = broadcast_count.fetch_add(1);
+  unsigned oldval = broadcast_count.fetch_add(1);
   if (oldval == THRD_COUNT - 1) {
     __llvm_libc::mtx_lock(&threads_ready_mtx);
     __llvm_libc::cnd_signal(&threads_ready_cnd);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124468.425260.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220426/47107dd6/attachment.bin>


More information about the libc-commits mailing list