]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
tools/xenstore: Consolidate PRINTF_ATTRIBUTE() in utils.h
authorJulien Grall <jgrall@amazon.com>
Fri, 5 Mar 2021 12:40:02 +0000 (12:40 +0000)
committerJulien Grall <jgrall@amazon.com>
Thu, 11 Mar 2021 09:44:51 +0000 (09:44 +0000)
At the moment PRINTF_ATTRIBUTE() is defined in two places:
    - tdb.h: Defined as a NOP
    - talloc.h: Defined as a NOP for GCC older than 3.0 otherwise will
    add the attribute to check the printf format

Xen requires to build with minimum GCC 4.1 and we want to check the
printf format for all the printf-like functions.

Only implement PRINTF_ATTRIBUTE() once in utils.h and drop the
conditional check for GCC < 3.0.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/xenstore/talloc.h
tools/xenstore/tdb.h
tools/xenstore/utils.h

index 71a36e7be06b81583276ac0d20cbd231f0666207..a0f4bff25788e6964cc42ad9f9c3b5af0fe4a49a 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <sys/types.h>
 
+#include "utils.h"
+
 /* this is only needed for compatibility with the old talloc */
 typedef void TALLOC_CTX;
 
@@ -84,19 +86,6 @@ typedef void TALLOC_CTX;
 #define talloc_destroy(ctx) talloc_free(ctx)
 #endif
 
-#ifndef PRINTF_ATTRIBUTE
-#if (__GNUC__ >= 3)
-/** Use gcc attribute to check printf fns.  a1 is the 1-based index of
- * the parameter containing the format, and a2 the index of the first
- * argument. Note that some gcc 2.x versions don't handle this
- * properly **/
-#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
-#else
-#define PRINTF_ATTRIBUTE(a1, a2)
-#endif
-#endif
-
-
 /* The following definitions come from talloc.c  */
 void *_talloc(const void *context, size_t size);
 void talloc_set_destructor(const void *ptr, int (*destructor)(void *));
index 557cf727b869c201e2492b9f01337a74b490775c..ce3c7339f884af1fb381266d729148aefe62f8c7 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __TDB_H__
 #define __TDB_H__
 
+#include "utils.h"
+
 /* 
    Unix SMB/CIFS implementation.
 
@@ -84,10 +86,6 @@ struct tdb_traverse_lock {
        uint32_t hash;
 };
 
-#ifndef PRINTF_ATTRIBUTE
-#define PRINTF_ATTRIBUTE(a,b)
-#endif
-
 /* this is the context structure that is returned from a db open */
 typedef struct tdb_context {
        char *name; /* the name of the database */
index df1cb9a3bac66a7743239e718ccb7b99cbec3811..3dfb96b556dd26d1d44ef3063abd09f399f7a435 100644 (file)
@@ -27,6 +27,8 @@ static inline bool strends(const char *a, const char *b)
  */
 const char *dump_state_align(FILE *fp);
 
+#define PRINTF_ATTRIBUTE(a1, a2) __attribute__((format (printf, a1, a2)))
+
 void barf(const char *fmt, ...) __attribute__((noreturn));
 void barf_perror(const char *fmt, ...) __attribute__((noreturn));