summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2010-11-10 09:05:58 +1030
committerRusty Russell <rusty@rustcorp.com.au>2010-11-10 09:05:58 +1030
commit1c005e1223d2f8f664ce4b3be6cd7eb4dd449844 (patch)
treef462829c4cc4e81b88c93d00d4d4042319522684
parent56dd95485204eb282f5d7684861a1b55bada5ef0 (diff)
compiler: shorten names of attributes, add UNUSED
The long names were unwieldy in practice; at risk of clashing, replace with shorter versions.
-rw-r--r--ccan/alloc/alloc.c10
-rw-r--r--ccan/compiler/_info14
-rw-r--r--ccan/compiler/compiler.h66
-rw-r--r--ccan/compiler/test/compile_fail-printf.c2
-rw-r--r--ccan/htable/htable.c6
-rw-r--r--ccan/ilog/ilog.c2
-rw-r--r--ccan/ilog/ilog.h8
-rw-r--r--ccan/iscsi/login.c2
-rw-r--r--ccan/iscsi/scsi-lowlevel.c2
-rw-r--r--ccan/jbitset/jbitset.h2
-rw-r--r--ccan/jmap/jmap.h2
-rw-r--r--ccan/likely/likely.h2
-rw-r--r--ccan/talloc/talloc.c2
-rw-r--r--ccan/talloc/talloc.h16
-rw-r--r--ccan/tap/tap.h8
-rw-r--r--ccan/tdb/open.c2
-rw-r--r--ccan/tdb/tdb.h2
-rw-r--r--ccan/tdb/tools/tdbtorture.c4
-rw-r--r--ccan/tdb2/tdb.c2
-rw-r--r--ccan/tdb2/tdb2.h2
-rw-r--r--ccan/tdb2/tools/tdbtorture.c4
21 files changed, 89 insertions, 71 deletions
diff --git a/ccan/alloc/alloc.c b/ccan/alloc/alloc.c
index 643efedc..64475078 100644
--- a/ccan/alloc/alloc.c
+++ b/ccan/alloc/alloc.c
@@ -527,9 +527,8 @@ static bool huge_allocated(struct header *head, unsigned long offset)
}
/* They want something really big. Aim for contiguous pages (slow). */
-static COLD_ATTRIBUTE
-void *huge_alloc(void *pool, unsigned long poolsize,
- unsigned long size, unsigned long align)
+static COLD void *huge_alloc(void *pool, unsigned long poolsize,
+ unsigned long size, unsigned long align)
{
struct header *head = pool;
struct huge_alloc *ha;
@@ -647,7 +646,7 @@ done:
return (char *)pool + ha->off;
}
-static COLD_ATTRIBUTE void
+static COLD void
huge_free(struct header *head, unsigned long poolsize, void *free)
{
unsigned long i, off, pgnum, free_off = (char *)free - (char *)head;
@@ -687,8 +686,7 @@ huge_free(struct header *head, unsigned long poolsize, void *free)
alloc_free(head, poolsize, ha);
}
-static COLD_ATTRIBUTE unsigned long
-huge_size(struct header *head, void *p)
+static COLD unsigned long huge_size(struct header *head, void *p)
{
unsigned long i, off = (char *)p - (char *)head;
struct huge_alloc *ha;
diff --git a/ccan/compiler/_info b/ccan/compiler/_info
index 31f6f0c7..c55ba22f 100644
--- a/ccan/compiler/_info
+++ b/ccan/compiler/_info
@@ -6,16 +6,18 @@
* compiler - macros for common compiler extensions
*
* Abstracts away some compiler hints. Currently these include:
- * - COLD_ATTRIBUTE
+ * - COLD
* For functions not called in fast paths (aka. cold functions)
- * - PRINTF_ATTRIBUTE
+ * - PRINTF_FMT
* For functions which take printf-style parameters.
- * - IDEMPOTENT_ATTRIBUTE
+ * - IDEMPOTENT
* For functions which return the same value for same parameters.
- * - NEEDED_ATTRIBUTE
+ * - NEEDED
* For functions and variables which must be emitted even if unused.
- * - UNNEEDED_ATTRIBUTE
+ * - UNNEEDED
* For functions and variables which need not be emitted if unused.
+ * - UNUSED
+ * For parameters which are not used.
* - IS_COMPILE_CONSTANT
* For using different tradeoffs for compiletime vs runtime evaluation.
*
@@ -29,7 +31,7 @@
*
* // Example of a (slow-path) logging function.
* static int log_threshold = 2;
- * static void COLD_ATTRIBUTE PRINTF_ATTRIBUTE(2,3)
+ * static void COLD PRINTF_FMT(2,3)
* logger(int level, const char *fmt, ...)
* {
* va_list ap;
diff --git a/ccan/compiler/compiler.h b/ccan/compiler/compiler.h
index 49088ac7..d57d814b 100644
--- a/ccan/compiler/compiler.h
+++ b/ccan/compiler/compiler.h
@@ -4,95 +4,111 @@
#if HAVE_ATTRIBUTE_COLD
/**
- * COLD_ATTRIBUTE - a function is unlikely to be called.
+ * COLD - a function is unlikely to be called.
*
* Used to mark an unlikely code path and optimize appropriately.
* It is usually used on logging or error routines.
*
* Example:
- * static void COLD_ATTRIBUTE moan(const char *reason)
+ * static void COLD moan(const char *reason)
* {
* fprintf(stderr, "Error: %s (%s)\n", reason, strerror(errno));
* }
*/
-#define COLD_ATTRIBUTE __attribute__((cold))
+#define COLD __attribute__((cold))
#else
-#define COLD_ATTRIBUTE
+#define COLD
#endif
#if HAVE_ATTRIBUTE_PRINTF
/**
- * PRINTF_ATTRIBUTE - a function takes printf-style arguments
+ * PRINTF_FMT - a function takes printf-style arguments
* @nfmt: the 1-based number of the function's format argument.
* @narg: the 1-based number of the function's first variable argument.
*
* This allows the compiler to check your parameters as it does for printf().
*
* Example:
- * void PRINTF_ATTRIBUTE(2,3) my_printf(const char *prefix,
- * const char *fmt, ...);
+ * void PRINTF_FMT(2,3) my_printf(const char *prefix, const char *fmt, ...);
*/
-#define PRINTF_ATTRIBUTE(nfmt, narg) \
+#define PRINTF_FMT(nfmt, narg) \
__attribute__((format(__printf__, nfmt, narg)))
#else
-#define PRINTF_ATTRIBUTE(nfmt, narg)
+#define PRINTF_FMT(nfmt, narg)
#endif
#if HAVE_ATTRIBUTE_CONST
/**
- * IDEMPOTENT_ATTRIBUTE - a function's return depends only on its argument
+ * IDEMPOTENT - a function's return depends only on its argument
*
* This allows the compiler to assume that the function will return the exact
* same value for the exact same arguments. This implies that the function
* must not use global variables, or dereference pointer arguments.
*/
-#define IDEMPOTENT_ATTRIBUTE __attribute__((const))
+#define IDEMPOTENT __attribute__((const))
#else
-#define IDEMPOTENT_ATTRIBUTE
+#define IDEMPOTENT
#endif
#if HAVE_ATTRIBUTE_UNUSED
/**
- * UNNEEDED_ATTRIBUTE - a parameter/variable/function may not be needed
+ * UNNEEDED - a variable/function may not be needed
*
- * This suppresses warnings about unused variables or parameters, but tells
+ * This suppresses warnings about unused variables or functions, but tells
* the compiler that if it is unused it need not emit it into the source code.
*
* Example:
* // With some preprocessor options, this is unnecessary.
- * static UNNEEDED_ATTRIBUTE int counter;
+ * static UNNEEDED int counter;
*
* // With some preprocessor options, this is unnecessary.
- * static UNNEEDED_ATTRIBUTE void add_to_counter(int add)
+ * static UNNEEDED void add_to_counter(int add)
* {
* counter += add;
* }
*/
-#define UNNEEDED_ATTRIBUTE __attribute__((unused))
+#define UNNEEDED __attribute__((unused))
#if HAVE_ATTRIBUTE_USED
/**
- * NEEDED_ATTRIBUTE - a parameter/variable/function is needed
+ * NEEDED - a variable/function is needed
*
- * This suppresses warnings about unused variables or parameters, but tells
+ * This suppresses warnings about unused variables or functions, but tells
* the compiler that it must exist even if it (seems) unused.
*
* Example:
* // Even if this is unused, these are vital for debugging.
- * static UNNEEDED_ATTRIBUTE int counter;
- * static UNNEEDED_ATTRIBUTE void dump_counter(void)
+ * static NEEDED int counter;
+ * static NEEDED void dump_counter(void)
* {
* printf("Counter is %i\n", counter);
* }
*/
-#define NEEDED_ATTRIBUTE __attribute__((used))
+#define NEEDED __attribute__((used))
#else
/* Before used, unused functions and vars were always emitted. */
-#define NEEDED_ATTRIBUTE __attribute__((unused))
+#define NEEDED __attribute__((unused))
#endif
+
+/**
+ * UNUSED - a parameter is unused
+ *
+ * Some compilers (eg. gcc with -W or -Wunused) warn about unused
+ * function parameters. This suppresses such warnings and indicates
+ * to the reader that it's deliberate.
+ *
+ * Example:
+ * // This is used as a callback, so needs to have this prototype.
+ * static int some_callback(void *unused UNUSED)
+ * {
+ * return 0;
+ * }
+ */
+#define UNUSED __attribute__((unused))
#else
-#define UNNEEDED_ATTRIBUTE
-#define NEEDED_ATTRIBUTE
+#define UNNEEDED
+#define NEEDED
+#define UNUSED
#endif
#if HAVE_BUILTIN_CONSTANT_P
diff --git a/ccan/compiler/test/compile_fail-printf.c b/ccan/compiler/test/compile_fail-printf.c
index 670126bb..8f34ae5a 100644
--- a/ccan/compiler/test/compile_fail-printf.c
+++ b/ccan/compiler/test/compile_fail-printf.c
@@ -1,6 +1,6 @@
#include <ccan/compiler/compiler.h>
-static void PRINTF_ATTRIBUTE(2,3) my_printf(int x, const char *fmt, ...)
+static void PRINTF_FMT(2,3) my_printf(int x, const char *fmt, ...)
{
}
diff --git a/ccan/htable/htable.c b/ccan/htable/htable.c
index 788e7189..a15c54d7 100644
--- a/ccan/htable/htable.c
+++ b/ccan/htable/htable.c
@@ -155,7 +155,7 @@ static void ht_add(struct htable *ht, const void *new, size_t h)
ht->table[i] = make_hval(ht, new, get_hash_ptr_bits(ht, h)|perfect);
}
-static COLD_ATTRIBUTE bool double_table(struct htable *ht)
+static COLD bool double_table(struct htable *ht)
{
unsigned int i;
size_t oldnum = (size_t)1 << ht->bits;
@@ -192,7 +192,7 @@ static COLD_ATTRIBUTE bool double_table(struct htable *ht)
return true;
}
-static COLD_ATTRIBUTE void rehash_table(struct htable *ht)
+static COLD void rehash_table(struct htable *ht)
{
size_t start, i;
uintptr_t e;
@@ -217,7 +217,7 @@ static COLD_ATTRIBUTE void rehash_table(struct htable *ht)
}
/* We stole some bits, now we need to put them back... */
-static COLD_ATTRIBUTE void update_common(struct htable *ht, const void *p)
+static COLD void update_common(struct htable *ht, const void *p)
{
unsigned int i;
uintptr_t maskdiff, bitsdiff;
diff --git a/ccan/ilog/ilog.c b/ccan/ilog/ilog.c
index 17fc14d2..7030b79a 100644
--- a/ccan/ilog/ilog.c
+++ b/ccan/ilog/ilog.c
@@ -16,7 +16,7 @@
year=1998,
note="\url{http://supertech.csail.mit.edu/papers/debruijn.pdf}"
}*/
-static UNNEEDED_ATTRIBUTE const unsigned char DEBRUIJN_IDX32[32]={
+static UNNEEDED const unsigned char DEBRUIJN_IDX32[32]={
0, 1,28, 2,29,14,24, 3,30,22,20,15,25,17, 4, 8,
31,27,13,23,21,19,16, 7,26,12,18, 6,11, 5,10, 9
};
diff --git a/ccan/ilog/ilog.h b/ccan/ilog/ilog.h
index fdb9ebab..55dd0098 100644
--- a/ccan/ilog/ilog.h
+++ b/ccan/ilog/ilog.h
@@ -24,7 +24,7 @@
* return 1U << ilog32(i-1);
* }
*/
-int ilog32(uint32_t _v) IDEMPOTENT_ATTRIBUTE;
+int ilog32(uint32_t _v) IDEMPOTENT;
/**
* ilog32_nz - Integer binary logarithm of a non-zero 32-bit value.
@@ -43,7 +43,7 @@ int ilog32(uint32_t _v) IDEMPOTENT_ATTRIBUTE;
* return ilog32_nz(i) - 1;
* }
*/
-int ilog32_nz(uint32_t _v) IDEMPOTENT_ATTRIBUTE;
+int ilog32_nz(uint32_t _v) IDEMPOTENT;
/**
* ilog64 - Integer binary logarithm of a 64-bit value.
@@ -55,7 +55,7 @@ int ilog32_nz(uint32_t _v) IDEMPOTENT_ATTRIBUTE;
* See Also:
* ilog64_nz(), ilog32()
*/
-int ilog64(uint64_t _v) IDEMPOTENT_ATTRIBUTE;
+int ilog64(uint64_t _v) IDEMPOTENT;
/**
* ilog64_nz - Integer binary logarithm of a non-zero 64-bit value.
@@ -67,7 +67,7 @@ int ilog64(uint64_t _v) IDEMPOTENT_ATTRIBUTE;
* See Also:
* ilog64(), ilog32_nz()
*/
-int ilog64_nz(uint64_t _v) IDEMPOTENT_ATTRIBUTE;
+int ilog64_nz(uint64_t _v) IDEMPOTENT;
/**
* STATIC_ILOG_32 - The integer logarithm of an (unsigned, 32-bit) constant.
diff --git a/ccan/iscsi/login.c b/ccan/iscsi/login.c
index 5863d883..bc0d6ffa 100644
--- a/ccan/iscsi/login.c
+++ b/ccan/iscsi/login.c
@@ -268,7 +268,7 @@ int iscsi_logout_async(struct iscsi_context *iscsi, iscsi_command_cb cb, void *p
return 0;
}
-int iscsi_process_logout_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, const unsigned char *hdr, int size UNNEEDED_ATTRIBUTE)
+int iscsi_process_logout_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, const unsigned char *hdr, int size UNUSED)
{
iscsi->is_loggedin = 0;
pdu->callback(iscsi, ISCSI_STATUS_GOOD, NULL, pdu->private_data);
diff --git a/ccan/iscsi/scsi-lowlevel.c b/ccan/iscsi/scsi-lowlevel.c
index 620916fe..7090401c 100644
--- a/ccan/iscsi/scsi-lowlevel.c
+++ b/ccan/iscsi/scsi-lowlevel.c
@@ -201,7 +201,7 @@ struct scsi_task *scsi_cdb_readcapacity10(int lba, int pmi)
* parse the data in blob and calcualte the size of a full readcapacity10 datain structure
*/
static int scsi_readcapacity10_datain_getfullsize(struct scsi_task *task
- UNNEEDED_ATTRIBUTE)
+ UNUSED)
{
return 8;
}
diff --git a/ccan/jbitset/jbitset.h b/ccan/jbitset/jbitset.h
index 4489a8f5..77a158c9 100644
--- a/ccan/jbitset/jbitset.h
+++ b/ccan/jbitset/jbitset.h
@@ -33,7 +33,7 @@ struct jbitset {
JError_t err;
const char *errstr;
};
-const char *COLD_ATTRIBUTE jbit_error_(struct jbitset *set);
+const char *COLD jbit_error_(struct jbitset *set);
/**
* jbit_error - test for an error in the a previous jbit_ operation.
diff --git a/ccan/jmap/jmap.h b/ccan/jmap/jmap.h
index 0b389b60..cfa2e26c 100644
--- a/ccan/jmap/jmap.h
+++ b/ccan/jmap/jmap.h
@@ -44,7 +44,7 @@ struct jmap {
unsigned long acc_index;
const char *funcname;
};
-const char *COLD_ATTRIBUTE jmap_error_(struct jmap *map);
+const char *COLD jmap_error_(struct jmap *map);
/* Debugging checks. */
static inline void jmap_debug_add_access(const struct jmap *map,
diff --git a/ccan/likely/likely.h b/ccan/likely/likely.h
index eed1f209..137cb861 100644
--- a/ccan/likely/likely.h
+++ b/ccan/likely/likely.h
@@ -39,7 +39,7 @@
* code path and optimize appropriately; see likely() above.
*
* See Also:
- * likely(), likely_stats(), UNLIKELY_FUNCTION_ATTRIBUTE (compiler.h)
+ * likely(), likely_stats(), COLD (compiler.h)
*
* Example:
* // Prints a warning if we overflow.
diff --git a/ccan/talloc/talloc.c b/ccan/talloc/talloc.c
index 1b96f90f..fdf8eebe 100644
--- a/ccan/talloc/talloc.c
+++ b/ccan/talloc/talloc.c
@@ -664,7 +664,7 @@ int talloc_unlink(const void *context, void *ptr)
/*
add a name to an existing pointer - va_list version
*/
-static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_FMT(2,0);
static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap)
{
diff --git a/ccan/talloc/talloc.h b/ccan/talloc/talloc.h
index 58b406e5..d27c6892 100644
--- a/ccan/talloc/talloc.h
+++ b/ccan/talloc/talloc.h
@@ -580,7 +580,7 @@ char *talloc_strndup(const void *t, const char *p, size_t n);
*
* talloc_set_name_const(ptr, ptr)
*/
-char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_FMT(2,3);
/**
* talloc_append_string - concatenate onto a tallocated string
@@ -610,7 +610,7 @@ char *WARN_UNUSED_RESULT talloc_append_string(char *orig, const char *append);
* talloc_set_name_const(ptr, ptr)
*/
char *WARN_UNUSED_RESULT talloc_asprintf_append(char *s, const char *fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
+ PRINTF_FMT(2,3);
/**
* talloc_vasprintf - vsprintf into a talloc buffer.
@@ -626,7 +626,8 @@ char *WARN_UNUSED_RESULT talloc_asprintf_append(char *s, const char *fmt, ...)
*
* talloc_set_name_const(ptr, ptr)
*/
-char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
+ PRINTF_FMT(2,0);
/**
* talloc_vasprintf_append - sprintf onto the end of a talloc buffer.
@@ -638,7 +639,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIB
* talloc_asprintf_append(), except it takes a va_list.
*/
char *WARN_UNUSED_RESULT talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
- PRINTF_ATTRIBUTE(2,0);
+ PRINTF_FMT(2,0);
/**
* talloc_set_type - force the name of a pointer to a particular type
@@ -714,7 +715,8 @@ int talloc_increase_ref_count(const void *ptr);
* without releasing the name. All of the memory is released when the ptr is
* freed using talloc_free().
*/
-const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+const char *talloc_set_name(const void *ptr, const char *fmt, ...)
+ PRINTF_FMT(2,3);
/**
* talloc_set_name_const - set a talloc pointer name to a string constant
@@ -745,7 +747,7 @@ void talloc_set_name_const(const void *ptr, const char *name);
* talloc_set_name(ptr, fmt, ....);
*/
void *talloc_named(const void *context, size_t size,
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
+ const char *fmt, ...) PRINTF_FMT(3,4);
/**
* talloc_named_const - create a specifically-named talloc pointer
@@ -788,7 +790,7 @@ void *talloc_check_name(const void *ptr, const char *name);
*
* talloc_named(NULL, 0, fmt, ...);
*/
-void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
+void *talloc_init(const char *fmt, ...) PRINTF_FMT(1,2);
/**
* talloc_total_size - get the bytes used by the pointer and its children
diff --git a/ccan/tap/tap.h b/ccan/tap/tap.h
index 46f0779e..395d245d 100644
--- a/ccan/tap/tap.h
+++ b/ccan/tap/tap.h
@@ -118,7 +118,7 @@ void plan_tests(unsigned int tests);
# define skip_end } while(0)
unsigned int _gen_result(int, const char *, const char *, unsigned int,
- const char *, ...) PRINTF_ATTRIBUTE(5, 6);
+ const char *, ...) PRINTF_FMT(5, 6);
/**
* diag - print a diagnostic message (use instead of printf/fprintf)
@@ -130,7 +130,7 @@ unsigned int _gen_result(int, const char *, const char *, unsigned int,
* Example:
* diag("Now running complex tests");
*/
-void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+void diag(const char *fmt, ...) PRINTF_FMT(1, 2);
/**
* skip - print a diagnostic message (use instead of printf/fprintf)
@@ -153,7 +153,7 @@ void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
* skip(1, "Don't have SOME_FEATURE");
* #endif
*/
-void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
+void skip(unsigned int n, const char *fmt, ...) PRINTF_FMT(2, 3);
/**
* todo_start - mark tests that you expect to fail.
@@ -183,7 +183,7 @@ void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
* ok(dwim(), "Did what the user wanted");
* todo_end();
*/
-void todo_start(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+void todo_start(const char *fmt, ...) PRINTF_FMT(1, 2);
/**
* todo_end - end of tests you expect to fail.
diff --git a/ccan/tdb/open.c b/ccan/tdb/open.c
index 399ed165..aa974431 100644
--- a/ccan/tdb/open.c
+++ b/ccan/tdb/open.c
@@ -151,7 +151,7 @@ struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
}
/* a default logging function */
-static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_FMT(3, 4);
static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
{
}
diff --git a/ccan/tdb/tdb.h b/ccan/tdb/tdb.h
index 01ff905a..5d1d63c0 100644
--- a/ccan/tdb/tdb.h
+++ b/ccan/tdb/tdb.h
@@ -82,7 +82,7 @@ typedef struct TDB_DATA {
typedef struct tdb_context TDB_CONTEXT;
typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
-typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
+typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_FMT(3, 4);
typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
struct tdb_logging_context {
diff --git a/ccan/tdb/tools/tdbtorture.c b/ccan/tdb/tools/tdbtorture.c
index 0d5bcd2b..fc219b8d 100644
--- a/ccan/tdb/tools/tdbtorture.c
+++ b/ccan/tdb/tools/tdbtorture.c
@@ -41,8 +41,8 @@ static int loopnum;
static int count_pipe;
static struct tdb_logging_context log_ctx;
-#ifdef PRINTF_ATTRIBUTE
-static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
+#ifdef PRINTF_FMT
+static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...) PRINTF_FMT(3,4);
#endif
static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...)
{
diff --git a/ccan/tdb2/tdb.c b/ccan/tdb2/tdb.c
index 4b02755c..e3b3c230 100644
--- a/ccan/tdb2/tdb.c
+++ b/ccan/tdb2/tdb.c
@@ -10,7 +10,7 @@ struct tdb_data tdb_null = { .dptr = NULL, .dsize = 0 };
/* all contexts, to ensure no double-opens (fcntl locks don't nest!) */
static struct tdb_context *tdbs = NULL;
-PRINTF_ATTRIBUTE(4, 5) static void
+PRINTF_FMT(4, 5) static void
null_log_fn(struct tdb_context *tdb,
enum tdb_debug_level level, void *priv,
const char *fmt, ...)
diff --git a/ccan/tdb2/tdb2.h b/ccan/tdb2/tdb2.h
index adaf6710..ee20a28d 100644
--- a/ccan/tdb2/tdb2.h
+++ b/ccan/tdb2/tdb2.h
@@ -80,7 +80,7 @@ struct tdb_context;
/* FIXME: Make typesafe */
typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
-typedef void (*tdb_logfn_t)(struct tdb_context *, enum tdb_debug_level, void *priv, const char *, ...) PRINTF_ATTRIBUTE(4, 5);
+typedef void (*tdb_logfn_t)(struct tdb_context *, enum tdb_debug_level, void *priv, const char *, ...) PRINTF_FMT(4, 5);
typedef uint64_t (*tdb_hashfn_t)(const void *key, size_t len, uint64_t seed,
void *priv);
diff --git a/ccan/tdb2/tools/tdbtorture.c b/ccan/tdb2/tools/tdbtorture.c
index 46dc1c72..2ac9a8de 100644
--- a/ccan/tdb2/tools/tdbtorture.c
+++ b/ccan/tdb2/tools/tdbtorture.c
@@ -43,8 +43,8 @@ static int count_pipe;
static union tdb_attribute log_attr;
static union tdb_attribute seed_attr;
-#ifdef PRINTF_ATTRIBUTE
-static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, void *private, const char *format, ...) PRINTF_ATTRIBUTE(4,5);
+#ifdef PRINTF_FMT
+static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, void *private, const char *format, ...) PRINTF_FMT(4,5);
#endif
static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, void *private, const char *format, ...)
{