lkml.org 
[lkml]   [2008]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kernel coding style for if ... else which cross #ifdef
On Sat, May 24, 2008 at 03:41:21PM +0100, Jeremy Fitzhardinge wrote:
> Willy Tarreau wrote:
> >You still have the possibility to use the "-0" trick :
> >
> > if (CFG_THINGY_LIMIT && x > (CONFIG_THINGY_LIMIT-0)) {...}
> >
>
> Oh, that's cute in a vile way. I hadn't seen it before.

I use it in some of my code (but moderately). It's particularly useful
for limit checking such as above. It's useful too when you want to use
the config value as an offset or a bit shift. Eg:

p = malloc(buf_size << (CONFIG_SHIFT-0));

Willy



\
 
 \ /
  Last update: 2008-05-24 16:49    [W:0.139 / U:0.796 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site