[libc-commits] [PATCH] D126831: [libc] add printf
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jun 2 01:26:24 PDT 2022
sivachandra added inline comments.
================
Comment at: libc/src/stdio/printf.cpp:34
+ int ret_val = printf_core::printf_main(&writer, format, args);
+ if (__llvm_libc::ferror(reinterpret_cast<::FILE *>(__llvm_libc::stdout)))
+ return -1;
----------------
You don't need to cast to `FILE *` and call `ferror`. You can directly call the `error` method.
Also, a use case like this makes me feel that the writer functions should return an int value which can be consumed by printf_main to process the error. That way, the file writer can `write_unlocked` and `error_unlocked` under a single lock/unlock.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126831/new/
https://reviews.llvm.org/D126831
More information about the libc-commits
mailing list