Skip to content

Commit aca0fa6

Browse files
DimitryAndriclundman
authored andcommitted
Rename several printf attributes declarations to __printf__
For kernel builds on FreeBSD, 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 the FreeBSD base system we usually use `__printflike` from `<sys/cdefs.h>`, but that does not apply to OpenZFS. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Dimitry Andric <dimitry@andric.com> Closes openzfs#18095
1 parent a10e3f8 commit aca0fa6

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

include/os/freebsd/spl/sys/cmn_err.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ extern "C" {
5252
#ifndef _ASM
5353

5454
extern void cmn_err(int, const char *, ...)
55-
__attribute__((format(printf, 2, 3)));
55+
__attribute__((format(__printf__, 2, 3)));
5656

5757
extern void vzcmn_err(zoneid_t, int, const char *, __va_list)
58-
__attribute__((format(printf, 3, 0)));
58+
__attribute__((format(__printf__, 3, 0)));
5959

6060
extern void vcmn_err(int, const char *, __va_list)
61-
__attribute__((format(printf, 2, 0)));
61+
__attribute__((format(__printf__, 2, 0)));
6262

6363
extern void zcmn_err(zoneid_t, int, const char *, ...)
64-
__attribute__((format(printf, 3, 4)));
64+
__attribute__((format(__printf__, 3, 4)));
6565

6666
extern void vzprintf(zoneid_t, const char *, __va_list)
67-
__attribute__((format(printf, 2, 0)));
67+
__attribute__((format(__printf__, 2, 0)));
6868

6969
extern void zprintf(zoneid_t, const char *, ...)
70-
__attribute__((format(printf, 2, 3)));
70+
__attribute__((format(__printf__, 2, 3)));
7171

7272
extern void vuprintf(const char *, __va_list)
73-
__attribute__((format(printf, 1, 0)));
73+
__attribute__((format(__printf__, 1, 0)));
7474

7575
extern void panic(const char *, ...)
76-
__attribute__((format(printf, 1, 2), __noreturn__));
76+
__attribute__((format(__printf__, 1, 2), __noreturn__));
7777

7878
#define cmn_err_once(ce, ...) \
7979
do { \

include/os/freebsd/spl/sys/kmem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ MALLOC_DECLARE(M_SOLARIS);
5555
typedef struct vmem vmem_t;
5656

5757
extern char *kmem_asprintf(const char *, ...)
58-
__attribute__((format(printf, 1, 2)));
58+
__attribute__((format(__printf__, 1, 2)));
5959
extern char *kmem_vasprintf(const char *fmt, va_list ap)
60-
__attribute__((format(printf, 1, 0)));
60+
__attribute__((format(__printf__, 1, 0)));
6161

6262
extern int kmem_scnprintf(char *restrict str, size_t size,
6363
const char *restrict fmt, ...);

include/sys/spa.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,9 @@ extern void spa_set_allocator(spa_t *spa, const char *allocator);
11271127

11281128
/* Miscellaneous support routines */
11291129
extern void spa_load_failed(spa_t *spa, const char *fmt, ...)
1130-
__attribute__((format(printf, 2, 3)));
1130+
__attribute__((format(__printf__, 2, 3)));
11311131
extern void spa_load_note(spa_t *spa, const char *fmt, ...)
1132-
__attribute__((format(printf, 2, 3)));
1132+
__attribute__((format(__printf__, 2, 3)));
11331133
extern void spa_activate_mos_feature(spa_t *spa, const char *feature,
11341134
dmu_tx_t *tx);
11351135
extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature);

include/sys/vdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern int zfs_nocacheflush;
5454
typedef boolean_t vdev_open_children_func_t(vdev_t *vd);
5555

5656
extern void vdev_dbgmsg(vdev_t *vd, const char *fmt, ...)
57-
__attribute__((format(printf, 2, 3)));
57+
__attribute__((format(__printf__, 2, 3)));
5858
extern void vdev_dbgmsg_print_tree(vdev_t *, int);
5959
extern int vdev_open(vdev_t *);
6060
extern void vdev_open_children(vdev_t *);

include/sys/zfs_debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extern int zfs_dbgmsg_enable;
6868
extern void __set_error(const char *file, const char *func, int line, int err);
6969
extern void __zfs_dbgmsg(char *buf);
7070
extern void __dprintf(boolean_t dprint, const char *file, const char *func,
71-
int line, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
71+
int line, const char *fmt, ...) __attribute__((format(__printf__, 5, 6)));
7272

7373
/*
7474
* Some general principles for using zfs_dbgmsg():

0 commit comments

Comments
 (0)