git: bcd9ea853b14 - main - zfs: rename several printf attribute declarations to __printf__
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Dec 2025 12:51:18 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=bcd9ea853b14c85a61eb9079c59e966eed336578
commit bcd9ea853b14c85a61eb9079c59e966eed336578
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-12-30 12:50:24 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-12-30 12:50:45 +0000
zfs: rename several printf attribute declarations to __printf__
For kernel builds, we redefine `__printf__` to `__freebsd_kprintf__`, to
support FreeBSD kernel printf(9) extensions with clang.
In OpenZFS various printf related functions are declared with
__attribute__((format(printf, X, Y))), so these won't work with the
above redefinition. With clang 21 and higher, this leads to errors
similar to:
sys/contrib/openzfs/module/zfs/spa_misc.c:414:38: error: passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]
414 | (void) vsnprintf(buf, sizeof (buf), fmt, adx);
| ^
Since attribute names can always be spelled with leading and trailing
double underscores, rename these instances.
Note that in FreeBSD proper we usually use `__printflike` from
<sys/cdefs.h>, but that does not apply to OpenZFS.
Reviewed by: emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54388
---
sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h | 16 ++++++++--------
sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h | 4 ++--
sys/contrib/openzfs/include/sys/spa.h | 4 ++--
sys/contrib/openzfs/include/sys/vdev.h | 2 +-
sys/contrib/openzfs/include/sys/zfs_debug.h | 2 +-
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
index 93dd1196d977..fa55b3917669 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
@@ -52,28 +52,28 @@ extern "C" {
#ifndef _ASM
extern void cmn_err(int, const char *, ...)
- __attribute__((format(printf, 2, 3)));
+ __attribute__((format(__printf__, 2, 3)));
extern void vzcmn_err(zoneid_t, int, const char *, __va_list)
- __attribute__((format(printf, 3, 0)));
+ __attribute__((format(__printf__, 3, 0)));
extern void vcmn_err(int, const char *, __va_list)
- __attribute__((format(printf, 2, 0)));
+ __attribute__((format(__printf__, 2, 0)));
extern void zcmn_err(zoneid_t, int, const char *, ...)
- __attribute__((format(printf, 3, 4)));
+ __attribute__((format(__printf__, 3, 4)));
extern void vzprintf(zoneid_t, const char *, __va_list)
- __attribute__((format(printf, 2, 0)));
+ __attribute__((format(__printf__, 2, 0)));
extern void zprintf(zoneid_t, const char *, ...)
- __attribute__((format(printf, 2, 3)));
+ __attribute__((format(__printf__, 2, 3)));
extern void vuprintf(const char *, __va_list)
- __attribute__((format(printf, 1, 0)));
+ __attribute__((format(__printf__, 1, 0)));
extern void panic(const char *, ...)
- __attribute__((format(printf, 1, 2), __noreturn__));
+ __attribute__((format(__printf__, 1, 2), __noreturn__));
#define cmn_err_once(ce, ...) \
do { \
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
index a9619d7d0219..4ae96c91a5f3 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
@@ -55,9 +55,9 @@ MALLOC_DECLARE(M_SOLARIS);
typedef struct vmem vmem_t;
extern char *kmem_asprintf(const char *, ...)
- __attribute__((format(printf, 1, 2)));
+ __attribute__((format(__printf__, 1, 2)));
extern char *kmem_vasprintf(const char *fmt, va_list ap)
- __attribute__((format(printf, 1, 0)));
+ __attribute__((format(__printf__, 1, 0)));
extern int kmem_scnprintf(char *restrict str, size_t size,
const char *restrict fmt, ...);
diff --git a/sys/contrib/openzfs/include/sys/spa.h b/sys/contrib/openzfs/include/sys/spa.h
index 2a4cc60c4aa8..db30b5a066de 100644
--- a/sys/contrib/openzfs/include/sys/spa.h
+++ b/sys/contrib/openzfs/include/sys/spa.h
@@ -1127,9 +1127,9 @@ extern void spa_set_allocator(spa_t *spa, const char *allocator);
/* Miscellaneous support routines */
extern void spa_load_failed(spa_t *spa, const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));
+ __attribute__((format(__printf__, 2, 3)));
extern void spa_load_note(spa_t *spa, const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));
+ __attribute__((format(__printf__, 2, 3)));
extern void spa_activate_mos_feature(spa_t *spa, const char *feature,
dmu_tx_t *tx);
extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature);
diff --git a/sys/contrib/openzfs/include/sys/vdev.h b/sys/contrib/openzfs/include/sys/vdev.h
index 510474d6c085..86f2235f03ac 100644
--- a/sys/contrib/openzfs/include/sys/vdev.h
+++ b/sys/contrib/openzfs/include/sys/vdev.h
@@ -54,7 +54,7 @@ extern int zfs_nocacheflush;
typedef boolean_t vdev_open_children_func_t(vdev_t *vd);
extern void vdev_dbgmsg(vdev_t *vd, const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));
+ __attribute__((format(__printf__, 2, 3)));
extern void vdev_dbgmsg_print_tree(vdev_t *, int);
extern int vdev_open(vdev_t *);
extern void vdev_open_children(vdev_t *);
diff --git a/sys/contrib/openzfs/include/sys/zfs_debug.h b/sys/contrib/openzfs/include/sys/zfs_debug.h
index 0f021d15157b..6fe5cf062c17 100644
--- a/sys/contrib/openzfs/include/sys/zfs_debug.h
+++ b/sys/contrib/openzfs/include/sys/zfs_debug.h
@@ -68,7 +68,7 @@ extern int zfs_dbgmsg_enable;
extern void __set_error(const char *file, const char *func, int line, int err);
extern void __zfs_dbgmsg(char *buf);
extern void __dprintf(boolean_t dprint, const char *file, const char *func,
- int line, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
+ int line, const char *fmt, ...) __attribute__((format(__printf__, 5, 6)));
/*
* Some general principles for using zfs_dbgmsg():