[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 13:40:19 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:
> 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.
I don't expect the number of errors to grow much, but I will make a followup patch adding the error values to `core_structs.h`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127517/new/
https://reviews.llvm.org/D127517
More information about the libc-commits
mailing list