[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] tools/xenstore: Consolidate PRINTF_ATTRIBUTE() in utils.h
commit 209b309e33ebbf8674a9d84fd73cce7f1e70e7eb Author: Julien Grall <jgrall@xxxxxxxxxx> AuthorDate: Fri Mar 5 12:40:02 2021 +0000 Commit: Julien Grall <jgrall@xxxxxxxxxx> CommitDate: Thu Mar 11 09:44:51 2021 +0000 tools/xenstore: Consolidate PRINTF_ATTRIBUTE() in utils.h 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> Reviewed-by: Juergen Gross <jgross@xxxxxxxx> Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx> --- 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 71a36e7be0..a0f4bff257 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 557cf727b8..ce3c7339f8 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 df1cb9a3ba..3dfb96b556 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)); -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |