Thread (4 messages) 4 messages, 3 authors, 2009-02-23

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

From: Greg KH <hidden>
Date: 2009-02-23 23:32:58
Also in: lkml

On Sun, Feb 22, 2009 at 12:21:10PM -0500, Mike Murphy wrote:
On Sun, Feb 22, 2009 at 1:48 AM, Frederic Weisbecker [off-list ref] wrote:
...
quoted
quoted
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help