Skip to content
Browse files

Allow format string checking with GCC.

  • Loading branch information...
1 parent fe2fbc0 commit 3d43464bf55fa5a465c21eac9d7879537676edad @jsonn jsonn committed Feb 28, 2012
Showing with 12 additions and 2 deletions.
  1. +2 −0 libarchive_fe/err.c
  2. +10 −2 libarchive_fe/err.h
View
2 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
View
12 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

0 comments on commit 3d43464

Please sign in to comment.
Something went wrong with that request. Please try again.