Skip to content

Conversation

@vonosmas
Copy link
Contributor

Explicitly cast 0 to size_t type to match fread() return type. This follows the pattern used elsewhere in this file, and fixes -Wshorten-64-to-32 warnings when building the test.

Explicitly cast 0 to size_t type to match fread() return type.
This follows the pattern used elsewhere in this file, and fixes
-Wshorten-64-to-32 warnings when building the test.
@vonosmas vonosmas requested a review from lntue November 17, 2025 22:04
@llvmbot llvmbot added the libc label Nov 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 17, 2025

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

Changes

Explicitly cast 0 to size_t type to match fread() return type. This follows the pattern used elsewhere in this file, and fixes -Wshorten-64-to-32 warnings when building the test.


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

1 Files Affected:

  • (modified) libc/test/src/stdio/fileop_test.cpp (+2-2)
diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index 02328042b92b3..ed4ba26ed8734 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -101,7 +101,7 @@ TEST_F(LlvmLibcFILETest, SimpleFileOperations) {
 
   // This is not a readable file.
   ASSERT_THAT(LIBC_NAMESPACE::fread(data, 1, 1, file),
-              returns(EQ(0)).with_errno(NE(0)));
+              returns(EQ(size_t(0))).with_errno(NE(0)));
 
   ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));
 
@@ -175,7 +175,7 @@ TEST_F(LlvmLibcFILETest, FOpenFWriteSizeGreaterThanOne) {
   // Trying to read more should fetch nothing.
   ASSERT_THAT(
       LIBC_NAMESPACE::fread(read_data, sizeof(MyStruct), WRITE_NMEMB, file),
-      returns(EQ(0)).with_errno(EQ(0)));
+      returns(EQ(size_t(0))).with_errno(EQ(0)));
   EXPECT_NE(LIBC_NAMESPACE::feof(file), 0);
   EXPECT_EQ(LIBC_NAMESPACE::ferror(file), 0);
   ASSERT_EQ(LIBC_NAMESPACE::fclose(file), 0);

@github-actions
Copy link

🐧 Linux x64 Test Results

The build succeeded and no tests ran. This is expected in some build configurations.

@vonosmas vonosmas merged commit 5bba4fd into llvm:main Nov 19, 2025
28 checks passed
@vonosmas vonosmas deleted the libc-warning-fixup branch November 19, 2025 05:42
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