[libc-commits] [PATCH] D127517: [libc] add integer writing to printf

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jun 28 11:50:01 PDT 2022

michaelrj added inline comments.

Comment at: libc/src/stdio/printf_core/write_int_converter.h:24
+  if(to_conv.conv_val_ptr == nullptr) 
+    return -3;
lntue wrote:
> How is this return value defined?  Aren't errors normally -1?  And do we have tests for this?
this check is not in any of the specifications, and is a convenience feature that I added. The return value is negative, since the return value for printf is negative on errors. As for why it's -3, that's because -1 and -2 are used for file writing errors, and this allows me as the developer to tell what the error was.

I have now added a test to check that it returns an error value when passed a null pointer.

  rG LLVM Github Monorepo



More information about the libc-commits mailing list