[libc-commits] [libc] [libc] Fix test passing negative value in timespec passed to nanosleep (PR #65346)
Mikhail R. Gadelha via libc-commits
libc-commits at lists.llvm.org
Tue Sep 5 09:12:02 PDT 2023
https://github.com/mikhailramalho created https://github.com/llvm/llvm-project/pull/65346:
This test was setting tv_nsec to a negative value, which as per the standard this is an EINVAL:
The value in the tv_nsec field was not in the range [0, 999999999] or tv_sec was negative.
https://man7.org/linux/man-pages/man2/nanosleep.2.html
>From 8316ba3f2a7ec55cc39f5da79ba6dbfd19f6cd40 Mon Sep 17 00:00:00 2001
From: "Mikhail R. Gadelha" <mikhail at igalia.com>
Date: Tue, 5 Sep 2023 13:06:00 -0300
Subject: [PATCH] [libc] Fix test passing negative value in timespec passed to
nanosleep
This test was setting tv_nsec to a negative value, which as per the
standard this is an EINVAL:
The value in the tv_nsec field was not in the range [0, 999999999]
or tv_sec was negative.
https://man7.org/linux/man-pages/man2/nanosleep.2.html
---
libc/test/src/time/gettimeofday_test.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/time/gettimeofday_test.cpp b/libc/test/src/time/gettimeofday_test.cpp
index 5edd61c6483697f..a852d4fd30ef120 100644
--- a/libc/test/src/time/gettimeofday_test.cpp
+++ b/libc/test/src/time/gettimeofday_test.cpp
@@ -25,7 +25,7 @@ TEST(LlvmLibcGettimeofday, SmokeTest) {
int ret = __llvm_libc::gettimeofday(&tv, tz);
ASSERT_EQ(ret, 0);
- int sleep_time = -sleep_times[i];
+ int sleep_time = sleep_times[i];
// Sleep for {sleep_time} microsceconds.
struct timespec tim = {0, sleep_time * 1000};
struct timespec tim2 = {0, 0};
More information about the libc-commits
mailing list