[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-4.15 1/2] tools/xenstore: Consolidate PRINTF_ATTRIBUTE() in utils.h
From: Julien Grall <jgrall@xxxxxxxxxx> 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@xxxxxxxxxx> --- tools/xenstore/talloc.h | 15 ++------------- tools/xenstore/tdb.h | 6 ++---- tools/xenstore/utils.h | 2 ++ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/tools/xenstore/talloc.h b/tools/xenstore/talloc.h index 71a36e7be06b..a0f4bff25788 100644 --- a/tools/xenstore/talloc.h +++ b/tools/xenstore/talloc.h @@ -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 *)); diff --git a/tools/xenstore/tdb.h b/tools/xenstore/tdb.h index 557cf727b869..ce3c7339f884 100644 --- a/tools/xenstore/tdb.h +++ b/tools/xenstore/tdb.h @@ -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 */ diff --git a/tools/xenstore/utils.h b/tools/xenstore/utils.h index df1cb9a3bac6..3dfb96b556dd 100644 --- a/tools/xenstore/utils.h +++ b/tools/xenstore/utils.h @@ -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)); -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |