From: Jens Axboe Date: Tue, 5 Jun 2018 17:11:03 +0000 (-0600) Subject: Move nowarn_snprintf.h to lib/ X-Git-Tag: fio-3.8~50 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=734f7d02ebea2c46799eeccbbea3d98d9e245e1b;hp=983a0680c14922cfcd66715cf8fc15b8f54f77ae Move nowarn_snprintf.h to lib/ Signed-off-by: Jens Axboe --- diff --git a/fio.h b/fio.h index b9a21782..6c897fc6 100644 --- a/fio.h +++ b/fio.h @@ -44,7 +44,7 @@ #include "io_u_queue.h" #include "workqueue.h" #include "steadystate.h" -#include "nowarn_snprintf.h" +#include "lib/nowarn_snprintf.h" #ifdef CONFIG_SOLARISAIO #include diff --git a/lib/nowarn_snprintf.h b/lib/nowarn_snprintf.h new file mode 100644 index 00000000..5c0f4d44 --- /dev/null +++ b/lib/nowarn_snprintf.h @@ -0,0 +1,24 @@ +#ifndef _NOWARN_SNPRINTF_H_ +#define _NOWARN_SNPRINTF_H_ + +#include +#include + +static inline int nowarn_snprintf(char *str, size_t size, const char *format, + ...) +{ + va_list args; + + 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); +#if __GNUC__ -0 >= 8 +#pragma GCC diagnostic pop "-Wformat-truncation" +#endif + va_end(args); +} + +#endif diff --git a/nowarn_snprintf.h b/nowarn_snprintf.h deleted file mode 100644 index 5c0f4d44..00000000 --- a/nowarn_snprintf.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _NOWARN_SNPRINTF_H_ -#define _NOWARN_SNPRINTF_H_ - -#include -#include - -static inline int nowarn_snprintf(char *str, size_t size, const char *format, - ...) -{ - va_list args; - - 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); -#if __GNUC__ -0 >= 8 -#pragma GCC diagnostic pop "-Wformat-truncation" -#endif - va_end(args); -} - -#endif diff --git a/verify-state.h b/verify-state.h index 39b0ed1a..6da1585b 100644 --- a/verify-state.h +++ b/verify-state.h @@ -4,7 +4,7 @@ #include #include #include -#include "nowarn_snprintf.h" +#include "lib/nowarn_snprintf.h" struct thread_rand32_state { uint32_t s[4];