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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux