tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
changing KASSERT()'s definition for non-diag kernels
hi folks.
as part of the GCC 4.8 preparation work, we're seeing many new
warnings where variables are only used inside KASSERT(), but
the non-diag kernel builds trigger errors.
my solution, rather than marking these variables with __USE(),
is to change KASSERT() into a real function that consumes its
arguments, but is still an empty function.
note that there is a re-direction to force the input to
KASSERT() to be an integer type, as it is called with all sorts
of types of input (pointers, values, boolean expressions..)
comments? suggestions?
.mrg.
Index: lib/libkern/libkern.h
===================================================================
RCS file: /cvsroot/src/sys/lib/libkern/libkern.h,v
retrieving revision 1.108
diff -p -r1.108 libkern.h
*** lib/libkern/libkern.h 28 Aug 2013 16:20:38 -0000 1.108
--- lib/libkern/libkern.h 19 Oct 2013 19:55:50 -0000
*************** tolower(int ch)
*** 194,207 ****
#define CTASSERT_UNSIGNED(x) __CTASSERT(((typeof(x))-1) >= 0)
#ifndef DIAGNOSTIC
! #define _DIAGASSERT(a) (void)0
! #ifdef lint
! #define KASSERTMSG(e, msg, ...) /* NOTHING */
! #define KASSERT(e) /* NOTHING */
! #else /* !lint */
! #define KASSERTMSG(e, msg, ...) ((void)0)
! #define KASSERT(e) ((void)0)
! #endif /* !lint */
#else /* DIAGNOSTIC */
#define _DIAGASSERT(a) assert(a)
#define KASSERTMSG(e, msg, ...) \
--- 194,212 ----
#define CTASSERT_UNSIGNED(x) __CTASSERT(((typeof(x))-1) >= 0)
#ifndef DIAGNOSTIC
! /*
! * Use actual inlines for these so that compilers see their arguments
! * as consumed in non-DIAG builds.
! */
! static __inline__ void __KASSERTMSG(int e, const char *msg, ...);
! static __inline__ void __KASSERT(int e);
! static __inline__ void
! __KASSERTMSG(int e, const char *msg, ...) { }
! static __inline__ void
! __KASSERT(int e) { }
! #define _DIAGASSERT(e) __KASSERT((int)(e))
! #define KASSERTMSG(e, msg, ...) __KASSERTMSG((int)(e), (msg), ## __VA_ARGS__)
! #define KASSERT(e) __KASSERT((int)(e))
#else /* DIAGNOSTIC */
#define _DIAGASSERT(a) assert(a)
#define KASSERTMSG(e, msg, ...) \
Home |
Main Index |
Thread Index |
Old Index