[libc-commits] [libc] [libc] Cast the error value to int (PR #172724)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Wed Dec 17 11:58:46 PST 2025
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/172724
The negative value represents an error and we already use cast in this scenario elsewhere.
>From ce700d64f1e83585ccd59250943bc5f13732e791 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Wed, 17 Dec 2025 19:56:20 +0000
Subject: [PATCH] [libc] Cast the error value to int
The negative value represents an error and we already use
cast in this scenario elsewhere.
---
libc/src/stdio/baremetal/vfprintf_internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/src/stdio/baremetal/vfprintf_internal.h b/libc/src/stdio/baremetal/vfprintf_internal.h
index 59a95ea23c89e..d38a56481bc37 100644
--- a/libc/src/stdio/baremetal/vfprintf_internal.h
+++ b/libc/src/stdio/baremetal/vfprintf_internal.h
@@ -30,7 +30,7 @@ LIBC_INLINE int write_hook(cpp::string_view str_view, void *cookie) {
auto result =
__llvm_libc_stdio_write(cookie, str_view.data(), str_view.size());
if (result <= 0)
- return result;
+ return static_cast<int>(result);
if (static_cast<size_t>(result) != str_view.size())
return printf_core::FILE_WRITE_ERROR;
return printf_core::WRITE_OK;
More information about the libc-commits
mailing list