[libc-commits] [libc] [libc][NFC] Fix Implicit Conversion Warning in getrandom Test (PR #155732)

via libc-commits libc-commits at lists.llvm.org
Wed Aug 27 17:57:14 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

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
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) {

``````````

</details>


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


More information about the libc-commits mailing list