From: Tim Kientzle Date: Fri, 22 Jul 2011 05:04:20 +0000 (-0400) Subject: GCC-specific printf argument checks. X-Git-Tag: v2.8.5~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97b1e575ceff175f1df26e2b9357e498db0e379f;p=thirdparty%2Flibarchive.git GCC-specific printf argument checks. SVN-Revision: 3495 --- diff --git a/libarchive/archive.h b/libarchive/archive.h index 5ca28eb36..23235a06b 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -98,6 +98,13 @@ # define __LA_DECL #endif +#if defined(__GNUC__) && __GNUC__ >= 3 +#define __LA_PRINTF(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#else +#define __LA_PRINTF(fmtarg, firstvararg) /* nothing */ +#endif + #ifdef __cplusplus extern "C" { #endif @@ -719,7 +726,7 @@ __LA_DECL const char *archive_format_name(struct archive *); __LA_DECL int archive_format(struct archive *); __LA_DECL void archive_clear_error(struct archive *); __LA_DECL void archive_set_error(struct archive *, int _err, - const char *fmt, ...); + const char *fmt, ...) __LA_PRINTF(3, 4); __LA_DECL void archive_copy_error(struct archive *dest, struct archive *src); __LA_DECL int archive_file_count(struct archive *); diff --git a/libarchive/archive_string.h b/libarchive/archive_string.h index 25d7a8b1e..782c1b162 100644 --- a/libarchive/archive_string.h +++ b/libarchive/archive_string.h @@ -44,6 +44,8 @@ #include #endif +#include "archive.h" + /* * Basic resizable/reusable string support a la Java's "StringBuffer." * @@ -134,10 +136,11 @@ void __archive_string_free(struct archive_string *); /* Like 'vsprintf', but resizes the underlying string as necessary. */ void __archive_string_vsprintf(struct archive_string *, const char *, - va_list); + va_list) __LA_PRINTF(2, 0); #define archive_string_vsprintf __archive_string_vsprintf -void __archive_string_sprintf(struct archive_string *, const char *, ...); +void __archive_string_sprintf(struct archive_string *, const char *, ...) + __LA_PRINTF(2, 3); #define archive_string_sprintf __archive_string_sprintf /* Allocates a fresh buffer and converts as (assumed to be UTF-8) into it.