drivers: usb: Removes use of assignment in if condition
PATCH 1/1 drivers: usb: Removes use of assignment in if condition
This patch fixes following checkpatch.pl issue:
ERROR: do not use assignment in if condition
--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/devio.c +2 -1
@@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) } } + intf =usb_ifnum_to_if (ps->dev, ctl->ifno);if (ps->dev->state !=USB_STATE_CONFIGURED ) retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) +else if (!intf) retval = -EINVAL ;else switch (ctl->ioctl_code) {
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 13 lines · Atul Kumar Pant
This patch fixes following checkpatch.pl issue:
ERROR: do not use assignment in if conditionSigned-off-by Atul Kumar Pant <[email protected]>--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/devio.c +0
-0
drivers/usb/core/devio.c static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · line 2339
Quoted 8 lines
drivers/usb/core/devio.c +2
-1@@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) } } + intf =usb_ifnum_to_if (ps->dev, ctl->ifno);if (ps->dev->state !=USB_STATE_CONFIGURED ) retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) +else if (!intf)
Did you mean to change the logic here by doing the calculation always? Does that change functionality?
The existing code is fine, running checkpatch on code outside of drivers/staging/ or on new patches you are writing, is generally discouraged as the code usually is older than checkpatch is :)
thanks,
greg k-h
Quoted 26 lines · Greg KH
Quoted 13 lines · Atul Kumar Pant
This patch fixes following checkpatch.pl issue:
ERROR: do not use assignment in if conditionSigned-off-by Atul Kumar Pant <[email protected]>--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/devio.c +0
-0drivers/usb/core/devio.c static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · line 2339
Quoted 8 lines
drivers/usb/core/devio.c +2
-1@@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) } } + intf =usb_ifnum_to_if (ps->dev, ctl->ifno);if (ps->dev->state !=USB_STATE_CONFIGURED ) retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) +else if (!intf)Did you mean to change the logic here by doing the calculation always? Does that change functionality?
Quoted 3 lines
The existing code is fine, running checkpatch on code outside of
drivers/staging/or on new patches you are writing, is generally discouraged as the code usually is older than checkpatch is :)
Understood. One question though, should we fix issues like no space before open parenthesis (e.g. if(val)) in the code that is outside of /drivers/staging/ ?
Quoted 4 lines
thanks,
greg k-h
Greg KH
maintainerQuoted 27 lines · Atul Kumar Pant
Quoted 26 lines · Greg KH
Quoted 13 lines · Atul Kumar Pant
This patch fixes following checkpatch.pl issue:
ERROR: do not use assignment in if conditionSigned-off-by Atul Kumar Pant <[email protected]>--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/devio.c +0
-0drivers/usb/core/devio.c static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · line 2339
Quoted 8 lines
drivers/usb/core/devio.c +2
-1@@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) } } + intf =usb_ifnum_to_if (ps->dev, ctl->ifno);if (ps->dev->state !=USB_STATE_CONFIGURED ) retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) +else if (!intf)Did you mean to change the logic here by doing the calculation always? Does that change functionality?
Quoted 7 lines
Quoted 3 lines
The existing code is fine, running checkpatch on code outside of
drivers/staging/or on new patches you are writing, is generally discouraged as the code usually is older than checkpatch is :)Understood. One question though, should we fix issues like no space before open parenthesis (e.g. if(val)) in the code that is outside of /drivers/staging/ ?
Only if the maintainer of that subsystem says it is ok to do so.
good luck!
greg k-h
Quoted 17 lines · Greg KH
Quoted 16 lines · Atul Kumar Pant
This patch fixes following checkpatch.pl issue:
ERROR: do not use assignment in if conditionSigned-off-by Atul Kumar Pant <[email protected]>--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/devio.c +0
-0@@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) } }
Quoted 9 lines
drivers/usb/core/devio.c static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · line 2339
Quoted 5 lines
drivers/usb/core/devio.c +2
-1+ intf =usb_ifnum_to_if (ps->dev, ctl->ifno);if (ps->dev->state !=USB_STATE_CONFIGURED ) retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) +else if (!intf)Did you mean to change the logic here by doing the calculation always? Does that change functionality?
Now the calculation of interface will be done always, which can be redundant. But this would not change the functionality.
Quoted 7 lines
The existing code is fine, running checkpatch on code outside of
drivers/staging/or on new patches you are writing, is generally discouraged as the code usually is older than checkpatch is :)thanks,
greg k-h
Greg KH
maintainerQuoted 27 lines · Atul Kumar Pant
Quoted 17 lines · Greg KH
Quoted 16 lines · Atul Kumar Pant
This patch fixes following checkpatch.pl issue:
ERROR: do not use assignment in if conditionSigned-off-by Atul Kumar Pant <[email protected]>--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/devio.c +0
-0@@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) } }Quoted 9 lines
drivers/usb/core/devio.c static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · line 2339
Quoted 5 lines
drivers/usb/core/devio.c +2
-1+ intf =usb_ifnum_to_if (ps->dev, ctl->ifno);if (ps->dev->state !=USB_STATE_CONFIGURED ) retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) +else if (!intf)Did you mean to change the logic here by doing the calculation always? Does that change functionality?
Quoted 2 lines
Now the calculation of interface will be done always, which can be redundant. But this would not change the functionality.
Yes, but it is now redundant, so this change isn't really needed, the original code is "more correct", please leave it as-is.
thanks,
greg k-h