int check_device(const char *path, boolean_t force,
boolean_t isspare, boolean_t iswholedisk);
boolean_t check_sector_size_database(char *path, int *sector_size);
-void vdev_error(const char *fmt, ...);
+void vdev_error(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
int check_file(const char *file, boolean_t force, boolean_t isspare);
void after_zpool_upgrade(zpool_handle_t *zhp);
boolean_t error_seen;
boolean_t is_force;
-/*PRINTFLIKE1*/
void
vdev_error(const char *fmt, ...)
{
"are present\n"),
raidz->zprl_type,
mirror->zprl_type,
+ (u_longlong_t)
raidz->zprl_parity,
+ (u_longlong_t)
mirror->zprl_children - 1,
+ (u_longlong_t)
mirror->zprl_children);
else
return (NULL);
"%llu are present\n"),
lastrep.zprl_type,
rep.zprl_type,
+ (u_longlong_t)
lastrep.zprl_parity,
+ (u_longlong_t)
rep.zprl_parity);
else
return (NULL);
"mismatched replication level: "
"both %llu and %llu device parity "
"%s vdevs are present\n"),
+ (u_longlong_t)
lastrep.zprl_parity,
- rep.zprl_parity,
+ (u_longlong_t)rep.zprl_parity,
rep.zprl_type);
else
return (NULL);
"mismatched replication level: "
"both %llu-way and %llu-way %s "
"vdevs are present\n"),
+ (u_longlong_t)
lastrep.zprl_children,
+ (u_longlong_t)
rep.zprl_children,
rep.zprl_type);
else
"and %s vdevs, %llu vs. %llu (%llu-way)\n"),
raidz->zprl_type,
mirror->zprl_type,
- raidz->zprl_parity,
- mirror->zprl_children - 1,
- mirror->zprl_children);
+ (u_longlong_t)raidz->zprl_parity,
+ (u_longlong_t)mirror->zprl_children - 1,
+ (u_longlong_t)mirror->zprl_children);
ret = -1;
}
} else if (strcmp(current->zprl_type, new->zprl_type) != 0) {
vdev_error(gettext(
"mismatched replication level: pool uses %llu "
"device parity and new vdev uses %llu\n"),
- current->zprl_parity, new->zprl_parity);
+ (u_longlong_t)current->zprl_parity,
+ (u_longlong_t)new->zprl_parity);
ret = -1;
} else if (current->zprl_children != new->zprl_children) {
vdev_error(gettext(
"mismatched replication level: pool uses %llu-way "
"%s and new vdev uses %llu-way %s\n"),
- current->zprl_children, current->zprl_type,
- new->zprl_children, new->zprl_type);
+ (u_longlong_t)current->zprl_children,
+ current->zprl_type,
+ (u_longlong_t)new->zprl_children,
+ new->zprl_type);
ret = -1;
}
}
extern void uu_alt_exit(int);
extern const char *uu_setpname(char *);
extern const char *uu_getpname(void);
-/*PRINTFLIKE1*/
-extern void uu_warn(const char *, ...);
-extern void uu_vwarn(const char *, va_list);
-/*PRINTFLIKE1*/
-extern void uu_die(const char *, ...) __NORETURN;
-extern void uu_vdie(const char *, va_list) __NORETURN;
-/*PRINTFLIKE2*/
-extern void uu_xdie(int, const char *, ...) __NORETURN;
-extern void uu_vxdie(int, const char *, va_list) __NORETURN;
+extern void uu_warn(const char *, ...)
+ __attribute__((format(printf, 1, 2)));
+extern void uu_vwarn(const char *, va_list)
+ __attribute__((format(printf, 1, 0)));
+extern void uu_die(const char *, ...)
+ __attribute__((format(printf, 1, 2))) __NORETURN;
+extern void uu_vdie(const char *, va_list)
+ __attribute__((format(printf, 1, 0))) __NORETURN;
+extern void uu_xdie(int, const char *, ...)
+ __attribute__((format(printf, 2, 3))) __NORETURN;
+extern void uu_vxdie(int, const char *, va_list)
+ __attribute__((format(printf, 2, 0))) __NORETURN;
/*
* Exit status functions (not to be used directly)
*/
#define UU_NELEM(a) (sizeof (a) / sizeof ((a)[0]))
-/*PRINTFLIKE1*/
-extern char *uu_msprintf(const char *format, ...);
+extern char *uu_msprintf(const char *format, ...)
+ __attribute__((format(printf, 1, 2)));
extern void *uu_zalloc(size_t);
extern char *uu_strdup(const char *);
extern void uu_free(void *);
void uu_set_error(uint_t);
-/*PRINTFLIKE1*/
-void uu_panic(const char *format, ...);
+void uu_panic(const char *format, ...) __attribute__((format(printf, 1, 2)));
/*
extern "C" {
#endif
-/*
- * Allow for version tests for compiler bugs and features.
- */
-#if defined(__GNUC__)
-#define __GNUC_VERSION \
- (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
-#else
-#define __GNUC_VERSION 0
-#endif
-
-#if defined(__ATTRIBUTE_IMPLEMENTED) || defined(__GNUC__)
-
-#if 0
-/*
- * analogous to lint's PRINTFLIKEn
- */
-#define __sun_attr___PRINTFLIKE__(__n) \
- __attribute__((__format__(printf, __n, (__n)+1)))
-#define __sun_attr___VPRINTFLIKE__(__n) \
- __attribute__((__format__(printf, __n, 0)))
-
-#define __sun_attr___KPRINTFLIKE__ __sun_attr___PRINTFLIKE__
-#define __sun_attr___KVPRINTFLIKE__ __sun_attr___VPRINTFLIKE__
-#else
-/*
- * Currently the openzfs codebase has a lot of formatting errors
- * which are not picked up in the linux build because they're not
- * doing formatting checks. LLVM's kprintf implementation doesn't
- * actually do format checks!
- *
- * For FreeBSD these break under gcc! LLVM shim'ed cmn_err as a
- * format attribute but also didn't check anything. If one
- * replaces it with the above, all of the format issues
- * in the codebase show up.
- *
- * Once those format string issues are addressed, the above
- * should be flipped on once again.
- */
-#define __sun_attr___PRINTFLIKE__(__n)
-#define __sun_attr___VPRINTFLIKE__(__n)
-#define __sun_attr___KPRINTFLIKE__(__n)
-#define __sun_attr___KVPRINTFLIKE__(__n)
-
-#endif
-
-/*
- * This one's pretty obvious -- the function never returns
- */
-#define __sun_attr___noreturn__ __attribute__((__noreturn__))
-
-/*
- * This is an appropriate label for functions that do not
- * modify their arguments, e.g. strlen()
- */
-#define __sun_attr___pure__ __attribute__((__pure__))
-
-/*
- * This is a stronger form of __pure__. Can be used for functions
- * that do not modify their arguments and don't depend on global
- * memory.
- */
-#define __sun_attr___const__ __attribute__((__const__))
-
-/*
- * structure packing like #pragma pack(1)
- */
-#define __sun_attr___packed__ __attribute__((__packed__))
-
-#define ___sun_attr_inner(__a) __sun_attr_##__a
-#define __sun_attr__(__a) ___sun_attr_inner __a
-
-#else /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */
-
-#define __sun_attr__(__a)
-
-#endif /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */
-
-/*
- * Shorthand versions for readability
- */
-
-#define __PRINTFLIKE(__n) __sun_attr__((__PRINTFLIKE__(__n)))
-#define __VPRINTFLIKE(__n) __sun_attr__((__VPRINTFLIKE__(__n)))
-#define __KPRINTFLIKE(__n) __sun_attr__((__KPRINTFLIKE__(__n)))
-#define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n)))
#if defined(_KERNEL) || defined(_STANDALONE)
#define __NORETURN __sun_attr__((__noreturn__))
#endif /* _KERNEL || _STANDALONE */
#ifndef _ASM
-/*PRINTFLIKE2*/
extern void cmn_err(int, const char *, ...)
- __KPRINTFLIKE(2);
+ __attribute__((format(printf, 2, 3)));
extern void vzcmn_err(zoneid_t, int, const char *, __va_list)
- __KVPRINTFLIKE(3);
+ __attribute__((format(printf, 3, 0)));
extern void vcmn_err(int, const char *, __va_list)
- __KVPRINTFLIKE(2);
+ __attribute__((format(printf, 2, 0)));
-/*PRINTFLIKE3*/
extern void zcmn_err(zoneid_t, int, const char *, ...)
- __KPRINTFLIKE(3);
+ __attribute__((format(printf, 3, 4)));
extern void vzprintf(zoneid_t, const char *, __va_list)
- __KVPRINTFLIKE(2);
+ __attribute__((format(printf, 2, 0)));
-/*PRINTFLIKE2*/
extern void zprintf(zoneid_t, const char *, ...)
- __KPRINTFLIKE(2);
+ __attribute__((format(printf, 2, 3)));
extern void vuprintf(const char *, __va_list)
- __KVPRINTFLIKE(1);
+ __attribute__((format(printf, 1, 0)));
-/*PRINTFLIKE1*/
extern void panic(const char *, ...)
- __KPRINTFLIKE(1) __NORETURN;
-
-extern void vpanic(const char *, __va_list)
- __KVPRINTFLIKE(1) __NORETURN;
+ __attribute__((format(printf, 1, 2))) __NORETURN;
#endif /* !_ASM */
#define CE_PANIC 3 /* panic */
#define CE_IGNORE 4 /* print nothing */
-extern void cmn_err(int, const char *, ...);
-extern void vcmn_err(int, const char *, va_list);
-extern void vpanic(const char *, va_list);
+extern void cmn_err(int, const char *, ...)
+ __attribute__((format(printf, 2, 3)));
+extern void vcmn_err(int, const char *, va_list)
+ __attribute__((format(printf, 2, 0)));
+extern void vpanic(const char *, va_list)
+ __attribute__((format(printf, 1, 0)));
#define fm_panic panic
extern spa_autotrim_t spa_get_autotrim(spa_t *spa);
/* Miscellaneous support routines */
-extern void spa_load_failed(spa_t *spa, const char *fmt, ...);
-extern void spa_load_note(spa_t *spa, const char *fmt, ...);
+extern void spa_load_failed(spa_t *spa, const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
+extern void spa_load_note(spa_t *spa, const char *fmt, ...)
+ __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);
typedef boolean_t vdev_open_children_func_t(vdev_t *vd);
-extern void vdev_dbgmsg(vdev_t *vd, const char *fmt, ...);
+extern void vdev_dbgmsg(vdev_t *vd, const char *fmt, ...)
+ __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 *);
#include <wchar.h>
#include <unistd.h>
-static const char PNAME_FMT[] = "%s: ";
-static const char ERRNO_FMT[] = ": %s\n";
-
static const char *pname;
static void
}
}
-static void
+static __attribute__((format(printf, 2, 0))) void
uu_warn_internal(int err, const char *format, va_list alist)
{
if (pname != NULL)
- (void) fprintf(stderr, PNAME_FMT, pname);
+ (void) fprintf(stderr, "%s: ", pname);
(void) vfprintf(stderr, format, alist);
if (strrchr(format, '\n') == NULL)
- (void) fprintf(stderr, ERRNO_FMT, strerror(err));
+ (void) fprintf(stderr, ": %s\n", strerror(err));
}
void
uu_warn_internal(errno, format, alist);
}
-/*PRINTFLIKE1*/
void
uu_warn(const char *format, ...)
{
va_end(alist);
}
-static void
+static __attribute__((format(printf, 2, 0))) __NORETURN void
uu_die_internal(int status, const char *format, va_list alist)
{
uu_warn_internal(errno, format, alist);
uu_die_internal(UU_EXIT_FATAL, format, alist);
}
-/*PRINTFLIKE1*/
void
uu_die(const char *format, ...)
{
uu_die_internal(status, format, alist);
}
-/*PRINTFLIKE2*/
void
uu_xdie(int status, const char *format, ...)
{
}
}
-/*PRINTFLIKE2*/
void
zfs_error_aux(libzfs_handle_t *hdl, const char *fmt, ...)
{
return (zfs_error_fmt(hdl, error, "%s", msg));
}
-/*PRINTFLIKE3*/
int
zfs_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...)
{
return (zfs_standard_error_fmt(hdl, error, "%s", msg));
}
-/*PRINTFLIKE3*/
int
zfs_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...)
{
return (zpool_standard_error_fmt(hdl, error, "%s", msg));
}
-/*PRINTFLIKE3*/
int
zpool_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...)
{
/*
* A safe form of asprintf() which will die if the allocation fails.
*/
-/*PRINTFLIKE2*/
char *
zfs_asprintf(libzfs_handle_t *hdl, const char *fmt, ...)
{
}
}
-/*PRINTFLIKE2*/
void
cmn_err(int ce, const char *fmt, ...)
{
#include "zutil_import.h"
-/*PRINTFLIKE2*/
-static void
+static __attribute__((format(printf, 2, 3))) void
zutil_error_aux(libpc_handle_t *hdl, const char *fmt, ...)
{
va_list ap;
}
}
-/*PRINTFLIKE3*/
-static int
+static __attribute__((format(printf, 3, 4))) int
zutil_error_fmt(libpc_handle_t *hdl, const char *error, const char *fmt, ...)
{
va_list ap;
if (error == ENOENT)
return (0);
- zutil_error_aux(hdl, strerror(error));
+ zutil_error_aux(hdl, "%s", strerror(error));
(void) zutil_error_fmt(hdl, EZFS_BADPATH, dgettext(
TEXT_DOMAIN, "cannot resolve path '%s'"), dir);
return (error);
dirp = opendir(path);
if (dirp == NULL) {
error = errno;
- zutil_error_aux(hdl, strerror(error));
+ zutil_error_aux(hdl, "%s", strerror(error));
(void) zutil_error_fmt(hdl, EZFS_BADPATH,
dgettext(TEXT_DOMAIN, "cannot open '%s'"), path);
return (error);
goto out;
}
- zutil_error_aux(hdl, strerror(error));
+ zutil_error_aux(hdl, "%s", strerror(error));
(void) zutil_error_fmt(hdl, EZFS_BADPATH, dgettext(
TEXT_DOMAIN, "cannot resolve path '%s'"), dir);
goto out;
if (error == ENOENT)
continue;
- zutil_error_aux(hdl, strerror(error));
+ zutil_error_aux(hdl, "%s", strerror(error));
(void) zutil_error_fmt(hdl, EZFS_BADPATH, dgettext(
TEXT_DOMAIN, "cannot resolve path '%s'"), dir[i]);
goto error;
if (io_offset + io_size > bdev->bd_inode->i_size) {
vdev_dbgmsg(zio->io_vd,
"Illegal access %llu size %llu, device size %llu",
- io_offset, io_size, i_size_read(bdev->bd_inode));
+ (u_longlong_t)io_offset,
+ (u_longlong_t)io_size,
+ (u_longlong_t)i_size_read(bdev->bd_inode));
return (SET_ERROR(EIO));
}
if ((do_warn) && (tuning) && ((tuning) != (value))) { \
cmn_err(CE_WARN, \
"ignoring tunable %s (using %llu instead)", \
- (#tuning), (value)); \
+ (#tuning), (u_longlong_t)(value)); \
} \
} while (0)
if (sls == NULL) {
spa_load_failed(spa, "spa_ld_log_sm_metadata(): bug "
"encountered: could not find log spacemap for "
- "TXG %ld [error %d]",
- metaslab_unflushed_txg(m), ENOENT);
+ "TXG %llu [error %d]",
+ (u_longlong_t)metaslab_unflushed_txg(m), ENOENT);
return (ENOENT);
}
sls->sls_mscount++;
int spa_allocators = 4;
-/*PRINTFLIKE2*/
void
spa_load_failed(spa_t *spa, const char *fmt, ...)
{
spa->spa_trust_config ? "trusted" : "untrusted", buf);
}
-/*PRINTFLIKE2*/
void
spa_load_note(spa_t *spa, const char *fmt, ...)
{
uint64_t zfs_vdev_max_auto_ashift = ASHIFT_MAX;
uint64_t zfs_vdev_min_auto_ashift = ASHIFT_MIN;
-/*PRINTFLIKE2*/
void
vdev_dbgmsg(vdev_t *vd, const char *fmt, ...)
{
vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_CORRUPT_DATA);
vdev_dbgmsg(vd, "vdev_load: zap_lookup(top_zap=%llu) "
- "failed [error=%d]", vd->vdev_top_zap, error);
+ "failed [error=%d]",
+ (u_longlong_t)vd->vdev_top_zap, error);
return (error);
}
}
break;
default:
gen_parity = NULL;
- cmn_err(CE_PANIC, "invalid RAID-Z configuration %d",
- raidz_parity(rm));
+ cmn_err(CE_PANIC, "invalid RAID-Z configuration %llu",
+ (u_longlong_t)raidz_parity(rm));
break;
}
rec_fn = reconstruct_fun_pqr_sel(rm, parity_valid, nbaddata);
break;
default:
- cmn_err(CE_PANIC, "invalid RAID-Z configuration %d",
- raidz_parity(rm));
+ cmn_err(CE_PANIC, "invalid RAID-Z configuration %llu",
+ (u_longlong_t)raidz_parity(rm));
break;
}