diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-06-27 14:53:17 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-28 07:06:45 -0700 |
commit | cacc1c8ac679b66876cf3e65c58f2bf874498050 (patch) | |
tree | 46a4dd00938bb027543309855bcc129e6eeca06b /common/printf.c | |
parent | 02b12a8b42d92f35e574ca954c1fe553fbfacd2a (diff) | |
download | chrome-ec-cacc1c8ac679b66876cf3e65c58f2bf874498050.tar.gz |
common/printf: snprintf: Return number of bytes on success
As indicated in the man page:
"""
Upon successful return, these functions return the number of
characters printed (excluding the null byte used to end output to
strings).
"""
There are no users of the return value currently in the EC code,
but this matters when doing fuzzing, as libFuzzer calls
std::to_string, which expects the correct return value.
BRANCH=none
BUG=chromium:854975
TEST=make buildfuzztests -j && ASAN_OPTIONS="log_path=stderr" \
build/host/usb_pd_fuzz/usb_pd_fuzz.exe -jobs=10
actually creates 10 output files.
TEST=make run-utils_str -j
Change-Id: If6a040f690dd847f4c88c3b8566554afdfbabc32
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1116625
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/printf.c')
-rw-r--r-- | common/printf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/common/printf.c b/common/printf.c index 1034058a50..37a0f42058 100644 --- a/common/printf.c +++ b/common/printf.c @@ -378,5 +378,5 @@ int vsnprintf(char *str, int size, const char *format, va_list args) /* Terminate string */ *ctx.str = '\0'; - return rv; + return (rv == EC_SUCCESS) ? (ctx.str - str) : -rv; } |