Replace /*PRINTFLIKEn*/ with attribute(printf)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Issue #12201
This commit is contained in:
наб
2021-06-05 13:14:12 +02:00
committed by Brian Behlendorf
parent 1373709450
commit 5dbf6c5a66
19 changed files with 76 additions and 164 deletions
-85
View File
@@ -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 */
+8 -15
View File
@@ -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 */