mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 08:56:13 +00:00
lib: add FMT_NSTD()
for non-standard printf exts
... to suppress the warnings when using something that isn't quite ISO C compatible and would otherwise cause compiler warnings from `-Wformat`. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
2d9a4e2931
commit
cb4928ce77
@ -251,6 +251,31 @@ static inline ssize_t bputch(struct fbuf *buf, char ch)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* when using non-ISO-C compatible extension specifiers... */
|
||||
|
||||
#ifdef _FRR_ATTRIBUTE_PRINTFRR
|
||||
#define FMT_NSTD_BEGIN
|
||||
#define FMT_NSTD_END
|
||||
#else /* !_FRR_ATTRIBUTE_PRINTFRR */
|
||||
#define FMT_NSTD_BEGIN \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wformat\"") \
|
||||
/* end */
|
||||
#define FMT_NSTD_END \
|
||||
_Pragma("GCC diagnostic pop") \
|
||||
/* end */
|
||||
#endif
|
||||
|
||||
#define FMT_NSTD(expr) \
|
||||
({ \
|
||||
typeof(expr) _v; \
|
||||
FMT_NSTD_BEGIN \
|
||||
_v = expr; \
|
||||
FMT_NSTD_END \
|
||||
_v; \
|
||||
}) \
|
||||
/* end */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -59,8 +59,8 @@ static void printcmp(const char *fmt, ...)
|
||||
errors++;
|
||||
}
|
||||
|
||||
static void printchk(const char *ref, const char *fmt, ...) PRINTFRR(2, 3);
|
||||
static void printchk(const char *ref, const char *fmt, ...)
|
||||
static int printchk(const char *ref, const char *fmt, ...) PRINTFRR(2, 3);
|
||||
static int printchk(const char *ref, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char bufrr[256];
|
||||
@ -125,6 +125,7 @@ static void printchk(const char *ref, const char *fmt, ...)
|
||||
(int)(outpos[i].off_end - outpos[i].off_start),
|
||||
bufrr + outpos[i].off_start);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
Loading…
Reference in New Issue
Block a user