[libc-commits] [libc] [libc] Add printf error handling (PR #162876)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Oct 31 10:04:21 PDT 2025


================
@@ -78,6 +83,23 @@ TEST(LlvmLibcFPrintfTest, WriteToFile) {
   written =
       LIBC_NAMESPACE::fprintf(file, "Writing to a read only file should fail.");
   EXPECT_LT(written, 0);
+  ASSERT_ERRNO_EQ(EBADF);
+
+  ASSERT_EQ(printf_test::fclose(file), 0);
+}
+
+#ifndef LIBC_COPT_PRINTF_NO_NULLPTR_CHECKS
----------------
michaelrj-google wrote:

this also needs to be guarded by `LIBC_COPT_PRINTF_DISABLE_WRITE_INT` if you want to use %n, since it might be disabled. You could also use %s and not have to worry about that.

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


More information about the libc-commits mailing list