-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/sprintf.[ch]: Add [v]snprintf_()
These functions are like [v]snprintf(3), but return -1 on truncation, which makes it easier to test. snprintf(3) is iseful in two cases: - We don't care if the output is truncated. snprintf(3) is fine for those, and the return value can be ignored. - Truncation is bad. In that case, it's as bad as a hard error (-1) from snprintf, so merging both problems into the same error code makes it easier to handle errors. Return the length if no truncation so that we can use it if necessary. Signed-off-by: Alejandro Colomar <[email protected]>
- Loading branch information
1 parent
1814877
commit 233370e
Showing
2 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters