Make nowarn_snprintf() call va_end()
authorBart Van Assche <bart.vanassche@wdc.com>
Tue, 5 Jun 2018 17:15:18 +0000 (19:15 +0200)
committerBart Van Assche <bart.vanassche@wdc.com>
Tue, 5 Jun 2018 17:16:52 +0000 (19:16 +0200)
This patch suppresses the following Coverity complaint:

CID 175867:  API usage errors  (VARARGS)
    va_end was not called for "args".

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
lib/nowarn_snprintf.h

index 5c0f4d44e4edff657b0bb5ea4a3dc52e6b0a51a5..81a6d10849c7edd49f585a027db6399d305cd94f 100644 (file)
@@ -8,17 +8,20 @@ static inline int nowarn_snprintf(char *str, size_t size, const char *format,
                                  ...)
 {
        va_list args;
+       int res;
 
        va_start(args, format);
 #if __GNUC__ -0 >= 8
 #pragma GCC diagnostic push "-Wformat-truncation"
 #pragma GCC diagnostic ignored "-Wformat-truncation"
 #endif
-       return vsnprintf(str, size, format, args);
+       res = vsnprintf(str, size, format, args);
 #if __GNUC__ -0 >= 8
 #pragma GCC diagnostic pop "-Wformat-truncation"
 #endif
        va_end(args);
+
+       return res;
 }
 
 #endif