Skip to content

Fix Print::printf return value on truncation and error#74

Open
l5yth wants to merge 2 commits into
meshtastic:masterfrom
l5yth:l5y-printf-return-value
Open

Fix Print::printf return value on truncation and error#74
l5yth wants to merge 2 commits into
meshtastic:masterfrom
l5yth:l5y-printf-return-value

Conversation

@l5yth

@l5yth l5yth commented Jun 2, 2026

Copy link
Copy Markdown
  • vsnprintf returns the would-be length (not bytes written) and a negative int on encoding error.
  • Storing that in size_t and returning it gave callers an overcount on truncation and ~SIZE_MAX on error.
  • Clamp to what actually fit and return write()'s byte count.
  • Fix Print::printf returns an incorrect byte count #72

@CLAassistant

CLAassistant commented Jun 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print::printf returns an incorrect byte count

2 participants