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@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
This commit is contained in:
Julien Grall committed 2021-03-11 09:44:51 +00:00
1 parent e4bdcc8aef
commit 209b309e33
3 files changed
+6 -17

No files matched your search

+2 -13
View 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 *));
+2 -4
View 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 */
+2
View 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));
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.