Re: [PATCH] (revision 1) input: xpad.c - Xbox 360 wireless andsysfs support

From: Greg KH
Date: Mon Feb 23 2009 - 18:32:58 EST


On Sun, Feb 22, 2009 at 12:21:10PM -0500, Mike Murphy wrote:
> On Sun, Feb 22, 2009 at 1:48 AM, Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:
> ...
> >> +static ssize_t xpad_store_rumble_enable(struct device *dev,
> >> + struct device_attribute *attr, const char *buf, size_t count)
> >> +{
> >> + struct usb_xpad *xpad = to_xpad(dev);
> >> + int newrumble = xpad->rumble_enable;
> >> + if (1 == sscanf(buf, "%d", &newrumble))
> >
> >
> > Oh, that's not wrong but it looks weird, usually, a code reader would
> > expect to see if (sscanf(...) == 1)
> >
>
> Oops... I changed some stuff around (deleted an unneeded variable) and
> didn't change the test form back.
>
> The "backwards" expression is a trick that some of us teach when
> teaching C, for the specific case of comparing a variable to a
> constant. It allows the compiler to check for an unintentional "="
> where a "==" was desired. (foo = 4) is not an error or a warning

Yes it is, on modern versions of gcc.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/