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 <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20643>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2023-01-12 09:08:45 +01:00
parent fa227969a3
commit 63203f94e8

View file

@ -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