Skip to content

Conversation

boomanaiden154
Copy link
Contributor

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.

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
\llvm#155627.
@llvmbot
Copy link
Member

llvmbot commented Aug 28, 2025

@llvm/pr-subscribers-libc

Author: Aiden Grossman (boomanaiden154)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/155732.diff

1 Files Affected:

  • (modified) libc/test/src/sys/random/linux/getrandom_test.cpp (+3-2)
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) {

@boomanaiden154 boomanaiden154 merged commit 0346e57 into llvm:main Aug 28, 2025
21 checks passed
@boomanaiden154 boomanaiden154 deleted the libc-bootstrapping-warning-getrandom branch August 28, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants