Skip to content

Commit

Permalink
Make nowarn_snprintf() call va_end()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KAGA-KOKO committed Jun 5, 2018
1 parent 734f7d0 commit 0b4a708
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/nowarn_snprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0b4a708

Please sign in to comment.