diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-07-11 10:21:49 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-13 15:46:35 +0000 |
commit | c8282f61e105490ed50120ec2d6a83a1e2ec1e08 (patch) | |
tree | 73047f4ef11b26e46ef90795a1c74c3c03932394 /include/printf.h | |
parent | cce493a388878334a65af95c4313ee051ef8a546 (diff) | |
download | chrome-ec-c8282f61e105490ed50120ec2d6a83a1e2ec1e08.tar.gz |
tree: Check return value from snprintf
snprintf returns a negative value on failure. The return value should be
checked to make sure that there were no errors.
BRANCH=none
BUG=b:238433667, b:234181908
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I64e2e69df7fa22c94f19acbbca8c6afbe6cf1ff1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3756174
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'include/printf.h')
-rw-r--r-- | include/printf.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/printf.h b/include/printf.h index 333e622b7b..370675ca46 100644 --- a/include/printf.h +++ b/include/printf.h @@ -99,7 +99,8 @@ __stdlib_compat int vfnprintf(int (*addchar)(void *context, int c), * @param format Format string * @return EC_SUCCESS, or EC_ERROR_OVERFLOW if the output was truncated. */ -__attribute__((__format__(__printf__, 3, 4))) __stdlib_compat int +__attribute__((__format__(__printf__, 3, 4))) +__warn_unused_result __stdlib_compat int crec_snprintf(char *str, size_t size, const char *format, ...); /** @@ -114,8 +115,8 @@ crec_snprintf(char *str, size_t size, const char *format, ...); * @return The string length written to str, or a negative value on error. * The negative values can be -EC_ERROR_INVAL or -EC_ERROR_OVERFLOW. */ -__stdlib_compat int crec_vsnprintf(char *str, size_t size, const char *format, - va_list args); +__warn_unused_result __stdlib_compat int +crec_vsnprintf(char *str, size_t size, const char *format, va_list args); #endif /* !HIDE_EC_STDLIB */ |