Skip to content

Commit d842f99

Browse files
Adrian Chaddbehlendorf
authored andcommitted
Fix compiling on FreeBSD + gcc - don't assume illmnos bits
This looks like it was once from the illumnos compat code. FreeBSD doesn't have cmn_err as a compiler format attribute, so it definitely errors out. It doesn't show up on LLVM because it doesn't trigger at all. Add in the format flags but keep them behind #if 0 for now; there are too many format issues that trigger when one does format checking in the shared code. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: adrian chadd <[email protected]> Closes #11068 Closes #11069
1 parent 8cad25a commit d842f99

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern "C" {
4848

4949
#if defined(__ATTRIBUTE_IMPLEMENTED) || defined(__GNUC__)
5050

51+
#if 0
5152
/*
5253
* analogous to lint's PRINTFLIKEn
5354
*/
@@ -56,28 +57,35 @@ extern "C" {
5657
#define __sun_attr___VPRINTFLIKE__(__n) \
5758
__attribute__((__format__(printf, __n, 0)))
5859

59-
/*
60-
* Handle the kernel printf routines that can take '%b' too
61-
*/
62-
#if __GNUC_VERSION < 30402
63-
/*
64-
* XX64 at least this doesn't work correctly yet with 3.4.1 anyway!
65-
*/
6660
#define __sun_attr___KPRINTFLIKE__ __sun_attr___PRINTFLIKE__
6761
#define __sun_attr___KVPRINTFLIKE__ __sun_attr___VPRINTFLIKE__
6862
#else
69-
#define __sun_attr___KPRINTFLIKE__(__n) \
70-
__attribute__((__format__(cmn_err, __n, (__n)+1)))
71-
#define __sun_attr___KVPRINTFLIKE__(__n) \
72-
__attribute__((__format__(cmn_err, __n, 0)))
63+
/*
64+
* Currently the openzfs codebase has a lot of formatting errors
65+
* which are not picked up in the linux build because they're not
66+
* doing formatting checks. LLVM's kprintf implementation doesn't
67+
* actually do format checks!
68+
*
69+
* For FreeBSD these break under gcc! LLVM shim'ed cmn_err as a
70+
* format attribute but also didn't check anything. If one
71+
* replaces it with the above, all of the format issues
72+
* in the codebase show up.
73+
*
74+
* Once those format string issues are addressed, the above
75+
* should be flipped on once again.
76+
*/
77+
#define __sun_attr___PRINTFLIKE__(__n)
78+
#define __sun_attr___VPRINTFLIKE__(__n)
79+
#define __sun_attr___KPRINTFLIKE__(__n)
80+
#define __sun_attr___KVPRINTFLIKE__(__n)
81+
7382
#endif
7483

7584
/*
7685
* This one's pretty obvious -- the function never returns
7786
*/
7887
#define __sun_attr___noreturn__ __attribute__((__noreturn__))
7988

80-
8189
/*
8290
* This is an appropriate label for functions that do not
8391
* modify their arguments, e.g. strlen()

0 commit comments

Comments
 (0)