From: Joerg Sonnenberger Date: Tue, 28 Feb 2012 15:48:01 +0000 (+0100) Subject: Allow format string checking with GCC. X-Git-Tag: v3.0.4~2^2~35^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6%2Fhead;p=thirdparty%2Flibarchive.git Allow format string checking with GCC. --- diff --git a/libarchive_fe/err.c b/libarchive_fe/err.c index eb3f9f3eb..a0173983a 100644 --- a/libarchive_fe/err.c +++ b/libarchive_fe/err.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include "err.h" +static void lafe_vwarnc(int, const char *, va_list) __LA_PRINTFLIKE(2, 0); + const char *lafe_progname; static void diff --git a/libarchive_fe/err.h b/libarchive_fe/err.h index dd7944813..ca1af3563 100644 --- a/libarchive_fe/err.h +++ b/libarchive_fe/err.h @@ -33,9 +33,17 @@ #define __LA_DEAD #endif +#if defined(__GNUC__) && (__GNUC__ > 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) +#define __LA_PRINTFLIKE(f,a) __attribute__((__format__(__printf__, f, a))) +#else +#define __LA_PRINTFLIKE(f,a) +#endif + extern const char *lafe_progname; -void lafe_warnc(int code, const char *fmt, ...); -void lafe_errc(int eval, int code, const char *fmt, ...) __LA_DEAD; +void lafe_warnc(int code, const char *fmt, ...) __LA_PRINTFLIKE(2, 3); +void lafe_errc(int eval, int code, const char *fmt, ...) __LA_DEAD + __LA_PRINTFLIKE(3, 4); #endif