lkml.org 
[lkml]   [1999]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Useful KERNEL_ASSERT Macro
On Sat, Jul 31, 1999 at 03:36:38PM -0500, Tim Hockin wrote:
>
> /* a general purpose kernel assert macro */
> #ifdef KERNEL_ASSERT_ON
> #define KERNEL_ASSERT(expr) if (!(expr)) \
> printk(KERN_DEBUG "KASSERT: %s:%d" \
> " - Assertion failed! (%s)\n", \
> __FILE__, __LINE__, #expr)
> #else
> #define KERNEL_ASSERT(expr)
> #endif
>

A failed assertion is SERIOUS (especially in drivers/filesystems) and should
lead to a KERNEL PANIC, preferredly with a system dump (which we don't have,
sic!) but at least with a call trace.

In general you should follow the C standard to depend on NDEBUG instead
of KERNEL_ASSERT_ON. IMHO development kernels should have NDEBUG undefined
resulting in assertions being evaluated, while production kernels should
have NDEBUG automatically defined resulting in _ALL_ debugging code being
disabled.

Yours,
Dominik Kubla
--
"Drug misuse is not a disease, it is a decision, like the decision to step
out in front of a moving car. You would call that not a disease but an
error of judgment." --Philip K. Dick. "Author's Note," A SCANNER DARKLY, 1977

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.447 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site