Skip to content

[libc] Add printf error handling #159474

@michaelrj-google

Description

@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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions