Module: Mesa Branch: main Commit: 63203f94e86ceb216dfe53410fed3c02d9b617ff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=63203f94e86ceb216dfe53410fed3c02d9b617ff
Author: Pierre-Eric Pelloux-Prayer <[email protected]> Date: Thu Jan 12 09:08:45 2023 +0100 util: add a return value to util_sprintf The regular sprintf is expected to return the number of char writter, so let's do the same in our version. Reviewed-by: Eric Engestrom <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20643> --- src/util/u_string.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/u_string.h b/src/util/u_string.h index 4700d9ca92f..8fead06b627 100644 --- a/src/util/u_string.h +++ b/src/util/u_string.h @@ -67,14 +67,15 @@ util_strchrnul(const char *s, char c) #ifdef _WIN32 #define sprintf util_sprintf -static inline void +static inline int PRINTFLIKE(2, 3) util_sprintf(char *str, const char *format, ...) { va_list ap; va_start(ap, format); - vsnprintf(str, INT_MAX, format, ap); + int r = vsnprintf(str, INT_MAX, format, ap); va_end(ap); + return r; } #define vasprintf util_vasprintf
