File: nowarn_snprintf.h

package info (click to toggle)
fio 3.25-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,812 kB
  • sloc: ansic: 69,429; python: 4,155; sh: 4,058; makefile: 749; yacc: 204; lex: 184
file content (27 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef _NOWARN_SNPRINTF_H_
#define _NOWARN_SNPRINTF_H_

#include <stdio.h>
#include <stdarg.h>

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
	res = vsnprintf(str, size, format, args);
#if __GNUC__ -0 >= 8
#pragma GCC diagnostic pop "-Wformat-truncation"
#endif
	va_end(args);

	return res;
}

#endif