[libc-commits] [libc] 99a8141 - [libc][test][NFC] Fix compiler warnings in libc tests (#212100)

via libc-commits libc-commits at lists.llvm.org
Sun Jul 26 14:03:10 PDT 2026


Author: Jeff Bailey
Date: 2026-07-26T22:03:05+01:00
New Revision: 99a8141b11cd8175b3d2fd81a83786083b6e7501

URL: https://github.com/llvm/llvm-project/commit/99a8141b11cd8175b3d2fd81a83786083b6e7501
DIFF: https://github.com/llvm/llvm-project/commit/99a8141b11cd8175b3d2fd81a83786083b6e7501.diff

LOG: [libc][test][NFC] Fix compiler warnings in libc tests (#212100)

Resolved compiler warnings in several libc unit and integration tests:

- Fixed -Wmissing-designated-field-initializers in localtime_r_test.cpp
by using zero-initialisation instead of partial designated initialisers.
- Fixed -Wimplicit-int-conversion in sigaltstack_test.cpp by explicitly
casting the loop index to uint8_t.
- Fixed -Wunused-parameter in pthread_barrier_test.cpp by omitting
unused parameter names in function definitions.

Assisted-by: Automated tooling, human reviewed.

Added: 
    

Modified: 
    libc/test/integration/src/pthread/pthread_barrier_test.cpp
    libc/test/src/signal/sigaltstack_test.cpp
    libc/test/src/time/localtime_r_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/integration/src/pthread/pthread_barrier_test.cpp b/libc/test/integration/src/pthread/pthread_barrier_test.cpp
index c8e11047e1d80..217895453612a 100644
--- a/libc/test/integration/src/pthread/pthread_barrier_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_barrier_test.cpp
@@ -26,7 +26,7 @@
 pthread_barrier_t barrier;
 LIBC_NAMESPACE::cpp::Atomic<int> counter;
 
-void *increment_counter_and_wait(void *args) {
+void *increment_counter_and_wait(void *) {
   counter.fetch_add(1);
   return reinterpret_cast<void *>(
       LIBC_NAMESPACE::pthread_barrier_wait(&barrier));
@@ -102,7 +102,7 @@ void reused_barrier_test() {
   LIBC_NAMESPACE::pthread_barrier_destroy(&barrier);
 }
 
-void *barrier_wait(void *in) {
+void *barrier_wait(void *) {
   return reinterpret_cast<void *>(
       LIBC_NAMESPACE::pthread_barrier_wait(&barrier));
 }

diff  --git a/libc/test/src/signal/sigaltstack_test.cpp b/libc/test/src/signal/sigaltstack_test.cpp
index 8c252c47452df..43c679b23bb29 100644
--- a/libc/test/src/signal/sigaltstack_test.cpp
+++ b/libc/test/src/signal/sigaltstack_test.cpp
@@ -33,7 +33,7 @@ static void handler(int) {
   // out or mapped to a register.
   uint8_t var[LOCAL_VAR_SIZE];
   for (int i = 0; i < LOCAL_VAR_SIZE; ++i)
-    var[i] = i;
+    var[i] = static_cast<uint8_t>(i);
   // Verify that array is completely on the alt_stack.
   for (int i = 0; i < LOCAL_VAR_SIZE; ++i) {
     if (!(uintptr_t(var + i) < uintptr_t(alt_stack + ALT_STACK_SIZE) &&

diff  --git a/libc/test/src/time/localtime_r_test.cpp b/libc/test/src/time/localtime_r_test.cpp
index 9ad73c8a0add4..bc71419d68c64 100644
--- a/libc/test/src/time/localtime_r_test.cpp
+++ b/libc/test/src/time/localtime_r_test.cpp
@@ -11,15 +11,7 @@
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcLocaltimeR, ValidUnixTimestamp0) {
-  struct tm input = {.tm_sec = 0,
-                     .tm_min = 0,
-                     .tm_hour = 0,
-                     .tm_mday = 0,
-                     .tm_mon = 0,
-                     .tm_year = 0,
-                     .tm_wday = 0,
-                     .tm_yday = 0,
-                     .tm_isdst = 0};
+  struct tm input = {};
   const time_t timer = 0;
 
   struct tm *result = LIBC_NAMESPACE::localtime_r(&timer, &input);
@@ -52,15 +44,7 @@ TEST(LlvmLibcLocaltimeR, NullPtr) {
 // This will be resolved a new pull request.
 
 TEST(LlvmLibcLocaltimeR, ValidUnixTimestamp) {
-  struct tm input = {.tm_sec = 0,
-                     .tm_min = 0,
-                     .tm_hour = 0,
-                     .tm_mday = 0,
-                     .tm_mon = 0,
-                     .tm_year = 0,
-                     .tm_wday = 0,
-                     .tm_yday = 0,
-                     .tm_isdst = 0};
+  struct tm input = {};
   const time_t timer = 1756595338;
   struct tm *result = LIBC_NAMESPACE::localtime_r(&timer, &input);
 
@@ -76,15 +60,7 @@ TEST(LlvmLibcLocaltimeR, ValidUnixTimestamp) {
 }
 
 TEST(LlvmLibcLocaltimeR, ValidUnixTimestampNegative) {
-  struct tm input = {.tm_sec = 0,
-                     .tm_min = 0,
-                     .tm_hour = 0,
-                     .tm_mday = 0,
-                     .tm_mon = 0,
-                     .tm_year = 0,
-                     .tm_wday = 0,
-                     .tm_yday = 0,
-                     .tm_isdst = 0};
+  struct tm input = {};
   const time_t timer = -1756595338;
   struct tm *result = LIBC_NAMESPACE::localtime_r(&timer, &input);
 


        


More information about the libc-commits mailing list