| 1 | #ifndef _NOWARN_SNPRINTF_H_ |
| 2 | #define _NOWARN_SNPRINTF_H_ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdarg.h> |
| 6 | |
| 7 | static inline int nowarn_snprintf(char *str, size_t size, const char *format, |
| 8 | ...) |
| 9 | { |
| 10 | va_list args; |
| 11 | int res; |
| 12 | |
| 13 | va_start(args, format); |
| 14 | #if __GNUC__ -0 >= 8 |
| 15 | #pragma GCC diagnostic push "-Wformat-truncation" |
| 16 | #pragma GCC diagnostic ignored "-Wformat-truncation" |
| 17 | #endif |
| 18 | res = vsnprintf(str, size, format, args); |
| 19 | #if __GNUC__ -0 >= 8 |
| 20 | #pragma GCC diagnostic pop "-Wformat-truncation" |
| 21 | #endif |
| 22 | va_end(args); |
| 23 | |
| 24 | return res; |
| 25 | } |
| 26 | |
| 27 | #endif |