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

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jun 28 12:27:24 PDT 2022

lntue accepted this revision.
lntue added inline comments.
This revision is now accepted and ready to land.

Comment at: libc/src/stdio/printf_core/write_int_converter.h:24
+  if(to_conv.conv_val_ptr == nullptr) 
+    return -3;
michaelrj wrote:
> 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.
Sound like we'll need some commonly defined macros for these values as the number of different errors grows.

  rG LLVM Github Monorepo



More information about the libc-commits mailing list