[libc-commits] [libc] [libc][NFC] Fix Implicit Conversion Warning in getrandom Test (PR #155732)
Aiden Grossman via libc-commits
libc-commits at lists.llvm.org
Wed Aug 27 17:56:39 PDT 2025
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/155732
getrandom returns a ssize_t, but the error codes are defined as integers. We need to use the builtin cast in the Fails matcher to ensure that everything is the same type.
clang will warn about this in a bootstrapping build. Originally found in \#155627.
>From 5f01fa56f4f7919a82127cdf536d75498570e848 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Thu, 28 Aug 2025 00:54:06 +0000
Subject: [PATCH] [libc][NFC] Fix Implicit Conversion Warning in getrandom Test
getrandom returns a ssize_t, but the error codes are defined as
integers. We need to use the builtin cast in the Fails matcher to ensure
that everything is the same type.
clang will warn about this in a bootstrapping build. Originally found in
\#155627.
---
libc/test/src/sys/random/linux/getrandom_test.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libc/test/src/sys/random/linux/getrandom_test.cpp b/libc/test/src/sys/random/linux/getrandom_test.cpp
index 70ecfbf80f12b..249942d89230c 100644
--- a/libc/test/src/sys/random/linux/getrandom_test.cpp
+++ b/libc/test/src/sys/random/linux/getrandom_test.cpp
@@ -19,11 +19,12 @@ using LlvmLibcGetRandomTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcGetRandomTest, InvalidFlag) {
LIBC_NAMESPACE::cpp::array<char, 10> buffer;
ASSERT_THAT(LIBC_NAMESPACE::getrandom(buffer.data(), buffer.size(), -1),
- Fails(EINVAL));
+ Fails<ssize_t>(EINVAL));
}
TEST_F(LlvmLibcGetRandomTest, InvalidBuffer) {
- ASSERT_THAT(LIBC_NAMESPACE::getrandom(nullptr, 65536, 0), Fails(EFAULT));
+ ASSERT_THAT(LIBC_NAMESPACE::getrandom(nullptr, 65536, 0),
+ Fails<ssize_t>(EFAULT));
}
TEST_F(LlvmLibcGetRandomTest, ReturnsSize) {
More information about the libc-commits
mailing list