Add return values to converter functions to allow for better error
handling when writing files. Also move the file writing code around to
be easier to read.
Details
- Reviewers
sivachandra lntue - Commits
- rG2e6eccfe34c1: [libc] refactor printf file writing
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nit: You should probably keep the addition of vfprintf_internal in the other patch.
libc/src/stdio/printf_core/char_converter.h | ||
---|---|---|
22 | Nit: If you make this macro take an argument, you can use like this: RETURN_ON_ERROR(writer->write(...)) | |
libc/src/stdio/printf_core/writer.cpp | ||
18 | Is this required now? | |
libc/src/stdio/printf_core/writer.h | ||
30 | Do we need this to be a signed integer now? |
libc/src/stdio/printf_core/file_writer.h | ||
---|---|---|
24 | Something I realized while reviewing the other patch: why should this internal class take a FILE* arg only to cast to the internal file data structure? |
address comments and move macro to a shared location
libc/src/stdio/printf_core/file_writer.h | ||
---|---|---|
24 | we have to cast it somewhere, and doing it inside vfprintf_internal means that we don't have to cast it in both fprintf and printf (and potentially also the v variants of those functions if those are added). | |
libc/src/stdio/printf_core/writer.h | ||
30 | It doesn't need to be an int, but it does make sense. Printf always returns an int, and that int is supposed to be the number of characters written, so storing the number of characters written in anything bigger doesn't really help. |
libc/src/stdio/printf_core/core_structs.h | ||
---|---|---|
84 | Nit: Put func in parenthesis: (func). |
Nit: If you make this macro take an argument, you can use like this: