* [PATCH] usb: class: usblp: Fixed assignments inside if conditions
@ 2017-05-13 5:50 Alberto Ladron
2017-05-16 5:44 ` kbuild test robot
0 siblings, 1 reply; 4+ messages in thread
From: Alberto Ladron @ 2017-05-13 5:50 UTC (permalink / raw)
To: zaitcev, gregkh; +Cc: linux-usb, linux-kernel, Alberto Ladron
Fixed coding style issues.
Signed-off-by: Alberto Ladron <alberto.ladron@gmail.com>
---
drivers/usb/class/usblp.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index fb87c17..b1879ff 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -362,7 +362,8 @@ static int usblp_check_status(struct usblp *usblp, int err)
int error;
mutex_lock(&usblp->mut);
- if ((error = usblp_read_status(usblp, usblp->statusbuf)) < 0) {
+ error = usblp_read_status(usblp, usblp->statusbuf);
+ if (error < 0) {
mutex_unlock(&usblp->mut);
printk_ratelimited(KERN_ERR
"usblp%d: error %d reading printer status\n",
@@ -735,14 +736,16 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
rv = -EINTR;
goto raise_biglock;
}
- if ((rv = usblp_wwait(usblp, !!(file->f_flags & O_NONBLOCK))) < 0)
+ rv = usblp_wwait(usblp, !!(file->f_flags & O_NONBLOCK));
+ if (rv < 0)
goto raise_wait;
while (writecount < count) {
/*
* Step 1: Submit next block.
*/
- if ((transfer_length = count - writecount) > USBLP_BUF_SIZE)
+ transfer_length = count - writecount;
+ if (transfer_length > USBLP_BUF_SIZE)
transfer_length = USBLP_BUF_SIZE;
rv = -ENOMEM;
@@ -760,7 +763,8 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
spin_lock_irq(&usblp->lock);
usblp->wcomplete = 0;
spin_unlock_irq(&usblp->lock);
- if ((rv = usb_submit_urb(writeurb, GFP_KERNEL)) < 0) {
+ rv = usb_submit_urb(writeurb, GFP_KERNEL);
+ if (rv < 0) {
usblp->wstatus = 0;
spin_lock_irq(&usblp->lock);
usblp->no_paper = 0;
@@ -835,8 +839,8 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
rv = usblp_rwait_and_lock(usblp, !!(file->f_flags & O_NONBLOCK));
if (rv < 0)
return rv;
-
- if ((avail = usblp->rstatus) < 0) {
+ avail = usblp->rstatus;
+ if (avail < 0) {
printk(KERN_ERR "usblp%d: error %d reading from printer\n",
usblp->minor, (int)avail);
usblp_submit_read(usblp);
@@ -851,7 +855,9 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
goto done;
}
- if ((usblp->readcount += count) == avail) {
+ usblp->readcount += count;
+
+ if (usblp->readcount == avail) {
if (usblp_submit_read(usblp) < 0) {
/* We don't want to leak USB return codes into errno. */
if (count == 0)
@@ -952,7 +958,8 @@ static int usblp_rwait_and_lock(struct usblp *usblp, int nonblock)
break;
}
set_current_state(TASK_INTERRUPTIBLE);
- if ((rc = usblp_rtest(usblp, nonblock)) < 0) {
+ rc = usblp_rtest(usblp, nonblock);
+ if (rc < 0) {
mutex_unlock(&usblp->mut);
break;
}
@@ -1010,7 +1017,8 @@ static int usblp_submit_read(struct usblp *usblp)
usblp->readcount = 0; /* XXX Why here? */
usblp->rcomplete = 0;
spin_unlock_irqrestore(&usblp->lock, flags);
- if ((rc = usb_submit_urb(urb, GFP_KERNEL)) < 0) {
+ rc = usb_submit_urb(urb, GFP_KERNEL);
+ if (rv < 0) {
dev_dbg(&usblp->intf->dev, "error submitting urb (%d)\n", rc);
spin_lock_irqsave(&usblp->lock, flags);
usblp->rstatus = rc;
@@ -1123,7 +1131,8 @@ static int usblp_probe(struct usb_interface *intf,
/* Malloc device ID string buffer to the largest expected length,
* since we can re-query it on an ioctl and a dynamic string
* could change in length. */
- if (!(usblp->device_id_string = kmalloc(USBLP_DEVICE_ID_SIZE, GFP_KERNEL))) {
+ usblp->device_id_string = kmalloc(USBLP_DEVICE_ID_SIZE, GFP_KERNEL);
+ if (!usblp->device_id_string) {
retval = -ENOMEM;
goto abort;
}
@@ -1133,7 +1142,8 @@ static int usblp_probe(struct usb_interface *intf,
* malloc both regardless of bidirectionality, because the
* alternate setting can be changed later via an ioctl.
*/
- if (!(usblp->readbuf = kmalloc(USBLP_BUF_SIZE_IN, GFP_KERNEL))) {
+ usblp->readbuf = kmalloc(USBLP_BUF_SIZE_IN, GFP_KERNEL);
+ if (!usblp->readbuf) {
retval = -ENOMEM;
goto abort;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: class: usblp: Fixed assignments inside if conditions
2017-05-13 5:50 [PATCH] usb: class: usblp: Fixed assignments inside if conditions Alberto Ladron
@ 2017-05-16 5:44 ` kbuild test robot
2017-05-17 0:37 ` Alberto Ladron
0 siblings, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2017-05-16 5:44 UTC (permalink / raw)
To: Alberto Ladron
Cc: kbuild-all, zaitcev, gregkh, linux-usb, linux-kernel, Alberto Ladron
[-- Attachment #1: Type: text/plain, Size: 2084 bytes --]
Hi Alberto,
[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.12-rc1 next-20170515]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Alberto-Ladron/usb-class-usblp-Fixed-assignments-inside-if-conditions/20170513-140010
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers//usb/class/usblp.c: In function 'usblp_submit_read':
>> drivers//usb/class/usblp.c:1021:6: error: 'rv' undeclared (first use in this function)
if (rv < 0) {
^~
drivers//usb/class/usblp.c:1021:6: note: each undeclared identifier is reported only once for each function it appears in
vim +/rv +1021 drivers//usb/class/usblp.c
1005 urb = usb_alloc_urb(0, GFP_KERNEL);
1006 if (urb == NULL)
1007 goto raise_urb;
1008
1009 usb_fill_bulk_urb(urb, usblp->dev,
1010 usb_rcvbulkpipe(usblp->dev,
1011 usblp->protocol[usblp->current_protocol].epread->bEndpointAddress),
1012 usblp->readbuf, USBLP_BUF_SIZE_IN,
1013 usblp_bulk_read, usblp);
1014 usb_anchor_urb(urb, &usblp->urbs);
1015
1016 spin_lock_irqsave(&usblp->lock, flags);
1017 usblp->readcount = 0; /* XXX Why here? */
1018 usblp->rcomplete = 0;
1019 spin_unlock_irqrestore(&usblp->lock, flags);
1020 rc = usb_submit_urb(urb, GFP_KERNEL);
> 1021 if (rv < 0) {
1022 dev_dbg(&usblp->intf->dev, "error submitting urb (%d)\n", rc);
1023 spin_lock_irqsave(&usblp->lock, flags);
1024 usblp->rstatus = rc;
1025 usblp->rcomplete = 1;
1026 spin_unlock_irqrestore(&usblp->lock, flags);
1027 goto raise_submit;
1028 }
1029
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38905 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: class: usblp: Fixed assignments inside if conditions
2017-05-16 5:44 ` kbuild test robot
@ 2017-05-17 0:37 ` Alberto Ladron
2017-05-17 8:09 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Alberto Ladron @ 2017-05-17 0:37 UTC (permalink / raw)
To: kbuild test robot; +Cc: kbuild-all, zaitcev, gregkh, linux-usb, linux-kernel
On Tue, May 16, 2017 at 01:44:47PM +0800, kbuild test robot wrote:
Hi,
Here is the fix. Or I have to resubmit the whole patch?
Signed-off-by: Alberto Ladron <alberto.ladron@gmail.com>
---
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index b1879ff..c335878 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1018,7 +1018,7 @@ static int usblp_submit_read(struct usblp *usblp)
usblp->rcomplete = 0;
spin_unlock_irqrestore(&usblp->lock, flags);
rc = usb_submit_urb(urb, GFP_KERNEL);
- if (rv < 0) {
+ if (rc < 0) {
dev_dbg(&usblp->intf->dev, "error submitting urb (%d)\n", rc);
spin_lock_irqsave(&usblp->lock, flags);
usblp->rstatus = rc;
> Hi Alberto,
>
> [auto build test ERROR on usb/usb-testing]
> [also build test ERROR on v4.12-rc1 next-20170515]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Alberto-Ladron/usb-class-usblp-Fixed-assignments-inside-if-conditions/20170513-140010
> base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
> config: x86_64-rhel (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64
>
> All errors (new ones prefixed by >>):
>
> drivers//usb/class/usblp.c: In function 'usblp_submit_read':
> >> drivers//usb/class/usblp.c:1021:6: error: 'rv' undeclared (first use in this function)
> if (rv < 0) {
> ^~
> drivers//usb/class/usblp.c:1021:6: note: each undeclared identifier is reported only once for each function it appears in
>
> vim +/rv +1021 drivers//usb/class/usblp.c
>
> 1005 urb = usb_alloc_urb(0, GFP_KERNEL);
> 1006 if (urb == NULL)
> 1007 goto raise_urb;
> 1008
> 1009 usb_fill_bulk_urb(urb, usblp->dev,
> 1010 usb_rcvbulkpipe(usblp->dev,
> 1011 usblp->protocol[usblp->current_protocol].epread->bEndpointAddress),
> 1012 usblp->readbuf, USBLP_BUF_SIZE_IN,
> 1013 usblp_bulk_read, usblp);
> 1014 usb_anchor_urb(urb, &usblp->urbs);
> 1015
> 1016 spin_lock_irqsave(&usblp->lock, flags);
> 1017 usblp->readcount = 0; /* XXX Why here? */
> 1018 usblp->rcomplete = 0;
> 1019 spin_unlock_irqrestore(&usblp->lock, flags);
> 1020 rc = usb_submit_urb(urb, GFP_KERNEL);
> > 1021 if (rv < 0) {
> 1022 dev_dbg(&usblp->intf->dev, "error submitting urb (%d)\n", rc);
> 1023 spin_lock_irqsave(&usblp->lock, flags);
> 1024 usblp->rstatus = rc;
> 1025 usblp->rcomplete = 1;
> 1026 spin_unlock_irqrestore(&usblp->lock, flags);
> 1027 goto raise_submit;
> 1028 }
> 1029
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: class: usblp: Fixed assignments inside if conditions
2017-05-17 0:37 ` Alberto Ladron
@ 2017-05-17 8:09 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2017-05-17 8:09 UTC (permalink / raw)
To: Alberto Ladron
Cc: kbuild test robot, kbuild-all, zaitcev, linux-usb, linux-kernel
On Tue, May 16, 2017 at 07:37:31PM -0500, Alberto Ladron wrote:
> On Tue, May 16, 2017 at 01:44:47PM +0800, kbuild test robot wrote:
> Hi,
>
> Here is the fix. Or I have to resubmit the whole patch?
The whole patch, of course, you can't break the build with any
individual patch, yours is long gone from the patch queue now :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-17 8:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-13 5:50 [PATCH] usb: class: usblp: Fixed assignments inside if conditions Alberto Ladron
2017-05-16 5:44 ` kbuild test robot
2017-05-17 0:37 ` Alberto Ladron
2017-05-17 8:09 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).