[F] Fix compilation warning

This commit is contained in:
seleznevae 2019-08-27 09:08:38 +03:00
parent f6d187a15f
commit 5ad27d67d3
2 changed files with 30 additions and 0 deletions

View File

@ -5588,6 +5588,15 @@ static int
vsnprintf_buffer(string_buffer_t *buffer, const struct ft_string *fmt, vsnprintf_buffer(string_buffer_t *buffer, const struct ft_string *fmt,
va_list *va) va_list *va)
{ {
/* Disable compiler diagnostic (format string is not a string literal) */
#if defined(FT_CLANG_COMPILER)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
#if defined(FT_GCC_COMPILER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
switch (buffer->type) { switch (buffer->type) {
case CHAR_BUF: case CHAR_BUF:
return vsnprintf(buffer->str.cstr, string_buffer_width_capacity(buffer), fmt->u.cstr, *va); return vsnprintf(buffer->str.cstr, string_buffer_width_capacity(buffer), fmt->u.cstr, *va);
@ -5603,6 +5612,12 @@ vsnprintf_buffer(string_buffer_t *buffer, const struct ft_string *fmt,
assert(0); assert(0);
return 0; return 0;
} }
#if defined(FT_CLANG_COMPILER)
#pragma clang diagnostic pop
#endif
#if defined(FT_GCC_COMPILER)
#pragma GCC diagnostic pop
#endif
} }
FT_INTERNAL FT_INTERNAL

View File

@ -608,6 +608,15 @@ static int
vsnprintf_buffer(string_buffer_t *buffer, const struct ft_string *fmt, vsnprintf_buffer(string_buffer_t *buffer, const struct ft_string *fmt,
va_list *va) va_list *va)
{ {
/* Disable compiler diagnostic (format string is not a string literal) */
#if defined(FT_CLANG_COMPILER)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
#if defined(FT_GCC_COMPILER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
switch (buffer->type) { switch (buffer->type) {
case CHAR_BUF: case CHAR_BUF:
return vsnprintf(buffer->str.cstr, string_buffer_width_capacity(buffer), fmt->u.cstr, *va); return vsnprintf(buffer->str.cstr, string_buffer_width_capacity(buffer), fmt->u.cstr, *va);
@ -623,6 +632,12 @@ vsnprintf_buffer(string_buffer_t *buffer, const struct ft_string *fmt,
assert(0); assert(0);
return 0; return 0;
} }
#if defined(FT_CLANG_COMPILER)
#pragma clang diagnostic pop
#endif
#if defined(FT_GCC_COMPILER)
#pragma GCC diagnostic pop
#endif
} }
FT_INTERNAL FT_INTERNAL