]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add __LA_PRINTF to enable format-string checks for GCC.
authorJoerg Sonnenberger <joerg.sonnenberger@gmail.com>
Thu, 25 Feb 2010 16:13:05 +0000 (11:13 -0500)
committerJoerg Sonnenberger <joerg.sonnenberger@gmail.com>
Thu, 25 Feb 2010 16:13:05 +0000 (11:13 -0500)
SVN-Revision: 1987

libarchive/archive.h
libarchive/archive_string.h

index e313778041d2d3b329d819bc56731963c75739de..5fcb688d67cdd880251a910e4ed175c16472034e 100644 (file)
 # 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
@@ -789,7 +796,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 *);
index 25d7a8b1e61c41dc42b84254bcae1b4ff12eafe2..782c1b162a7d595224dc09f033523e79a17d9520 100644 (file)
@@ -44,6 +44,8 @@
 #include <wchar.h>
 #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.