[libc-commits] [libc] [libc][test][NFC] Fix compiler warnings in libc tests (PR #212100)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Sun Jul 26 00:58:41 PDT 2026
https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/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.
>From 89188abca49323394178cb53943758614d4229b3 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Sun, 26 Jul 2026 08:57:12 +0100
Subject: [PATCH] [libc][test][NFC] Fix compiler warnings in libc tests
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.
---
.../src/pthread/pthread_barrier_test.cpp | 4 +--
libc/test/src/signal/sigaltstack_test.cpp | 2 +-
libc/test/src/time/localtime_r_test.cpp | 30 ++-----------------
3 files changed, 6 insertions(+), 30 deletions(-)
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