| Issue |
159474
|
| Summary |
[libc] Add printf error handling
|
| Labels |
libc
|
| Assignees |
|
| Reporter |
michaelrj-google
|
Currently printf never sets errno, which is incorrect. The file variants should propogate errors from the file they're writing to and every variant should set `EOVERFLOW` if the return value would overflow an `int`. Currently the `Writer` class stores the number of chars written as an `int`, so it should be changed to something larger and probably unsigned. I'd recommend either `size_t` or `uint64_t`.
It's important to remember that errno should only be set in public functions before returning, not in internal helpers. The return value of `printf_main` might need to be changed to be a struct with `size_t` char count and an error code.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs