aboutsummaryrefslogtreecommitdiffstats
path: root/include/os
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-06-05 13:14:12 +0200
committerBrian Behlendorf <[email protected]>2021-07-26 12:07:15 -0700
commit5dbf6c5a66d3de65f1b0436c8e83097dd49ff059 (patch)
tree59d33400d59c4935afcd37bbbf0263dd96cac71f /include/os
parent13737094503a38a219f1ffe641cb257bb4b879cb (diff)
Replace /*PRINTFLIKEn*/ with attribute(printf)
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Issue #12201
Diffstat (limited to 'include/os')
-rw-r--r--include/os/freebsd/spl/sys/ccompile.h85
-rw-r--r--include/os/freebsd/spl/sys/cmn_err.h23
-rw-r--r--include/os/linux/spl/sys/cmn_err.h9
3 files changed, 14 insertions, 103 deletions
diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h
index 7109d42ff..997044310 100644
--- a/include/os/freebsd/spl/sys/ccompile.h
+++ b/include/os/freebsd/spl/sys/ccompile.h
@@ -36,91 +36,6 @@
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 */
diff --git a/include/os/freebsd/spl/sys/cmn_err.h b/include/os/freebsd/spl/sys/cmn_err.h
index ba4cff37d..bf41ecdb2 100644
--- a/include/os/freebsd/spl/sys/cmn_err.h
+++ b/include/os/freebsd/spl/sys/cmn_err.h
@@ -49,36 +49,29 @@ extern "C" {
#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 */
diff --git a/include/os/linux/spl/sys/cmn_err.h b/include/os/linux/spl/sys/cmn_err.h
index 314bbbaf9..79297067c 100644
--- a/include/os/linux/spl/sys/cmn_err.h
+++ b/include/os/linux/spl/sys/cmn_err.h
@@ -32,9 +32,12 @@
#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