From: Mathieu Desnoyers Date: Wed, 15 May 2013 05:46:04 +0000 (+0200) Subject: snprintf: play nice with static checker X-Git-Tag: v2.2.0-rc3~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=402147a0ffcc8fb0a1784a6d880fac318038e686;p=lttng-ust.git snprintf: play nice with static checker Coverity complains that we pass a singleton as an array. Transform it into an array of size 1. Signed-off-by: Mathieu Desnoyers --- diff --git a/snprintf/snprintf.c b/snprintf/snprintf.c index bbc66a07..a6263979 100644 --- a/snprintf/snprintf.c +++ b/snprintf/snprintf.c @@ -38,10 +38,12 @@ #include "local.h" #include "ust_snprintf.h" +#define DUMMY_LEN 1 + int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap) { int ret; - char dummy; + char dummy[DUMMY_LEN]; LTTNG_UST_LFILE f; struct __lttng_ust_sfileext fext; @@ -50,8 +52,8 @@ int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap) n = INT_MAX; /* Stdio internals do not deal correctly with zero length buffer */ if (n == 0) { - str = &dummy; - n = 1; + str = dummy; + n = DUMMY_LEN; } _FILEEXT_SETUP(&f, &fext); f._file = -1;