[libc-commits] [libc] [libc] Cast the error value to int (PR #172724)

via libc-commits libc-commits at lists.llvm.org
Wed Dec 17 11:59:11 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Petr Hosek (petrhosek)

<details>
<summary>Changes</summary>

The negative value represents an error and we already use cast in this scenario elsewhere.

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


1 Files Affected:

- (modified) libc/src/stdio/baremetal/vfprintf_internal.h (+1-1) 


``````````diff
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;

``````````

</details>


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


More information about the libc-commits mailing list