lkml.org 
[lkml]   [2009]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 1/1] smi_detector: A System Management Interrupt detector
On Tue, 09 Jun 2009 17:50:01 -0400
Jon Masters <jonathan@jonmasters.org> wrote:

> > > + if (0 != err)
> >
> > if (err != 0)
> >
> > or
> >
> > if (err)
> >
> > would be more typical.
>
> The former runs the risk of assignment,

yup, which is why gcc will warn if you do

if (err = 0)
If you really meant to do that, then gcc can be silenced by
double-parenthesising. We consider this "good enough" for kernel
purposes, so we generally don't use the `if (CONSTANT == variable)' trick.

> whereas <value> != <variable>
> will generate a compiler error if it goes wrong, so I trained myself to
> always do that. The desired value is zero, so I prefer to show that in
> the test, but I have changed it following your advice anyway - it's like
> how I have to force myself not to use '{' '}' on single line
> if-statements despite generally doing so, again for safety :)


\
 
 \ /
  Last update: 2009-06-10 00:01    [W:0.079 / U:0.052 seconds]
©2003-2014 Jasper Spaans. Advertise on this site