From f059bd1ebfc4cf2e96c4639ad7fa6cf3a3198a2f Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Fri, 10 Mar 2017 03:28:43 +0000 Subject: Import dtc 1.4.3 Obtained from: https://www.kernel.org/pub/software/utils/dtc/dtc-1.4.3.tar.gz --- util.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index ccfdf4b124337..bc3d223fa6e3e 100644 --- a/util.h +++ b/util.h @@ -27,13 +27,20 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -static inline void __attribute__((noreturn)) die(const char *str, ...) +#ifdef __GNUC__ +static inline void +__attribute__((noreturn)) __attribute__((format (printf, 1, 2))) +die(const char *str, ...) +#else +static inline void die(const char *str, ...) +#endif { va_list ap; va_start(ap, str); fprintf(stderr, "FATAL ERROR: "); vfprintf(stderr, str, ap); + va_end(ap); exit(1); } @@ -52,12 +59,19 @@ static inline void *xrealloc(void *p, size_t len) void *new = realloc(p, len); if (!new) - die("realloc() failed (len=%d)\n", len); + die("realloc() failed (len=%zd)\n", len); return new; } extern char *xstrdup(const char *s); + +#ifdef __GNUC__ +extern int __attribute__((format (printf, 2, 3))) +xasprintf(char **strp, const char *fmt, ...); +#else +extern int xasprintf(char **strp, const char *fmt, ...); +#endif extern char *join_path(const char *path, const char *name); /** -- cgit v1.2.3