lkml.org 
[lkml]   [1999]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] *(int*)0 = 0 & variations
Date
From
adve@oce.nl (Arjan van de Ven) said:
> Riley Williams had the wisdom to write:
> RW> +#ifdef DEBUG
> RW> +#define kassert(cond) if (!(cond)) \
> RW> + printk(KERN_DEBUG "ASSERTION FAILURE: %s line %u: %s\n", \
> RW> + __FILE__, __LINE__, "cond")
> RW> +#else
> RW> +#define kassert(cond)
> RW> +#endif

> Please modify the second kassert to
>
>
> #define kassert(cond) if (cond) ;
>
> That way,
>
> kassert(var++)
>
> works the same with and without DEBUG.
>
> (I know, one shouldn't change a variable in an assert, but there is NO
> decent way to find such bugs)

Better write:

do { (void)(cond); } while(0)

then (your if can screw up other ifs).
--
Dr. Horst H. von Brand mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513

-
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:52    [W:0.067 / U:0.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site