Re: [PATCH 2/3] cdc-wdm: unify error handling in write

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

 



Oliver Neukum <oneukum@xxxxxxx> writes:

> On Fri, 2015-03-20 at 15:02 +0100, Bjørn Mork wrote:
>> Oliver Neukum <oneukum@xxxxxxx> writes:
>> 
>> > This makes sure the error handling path is the same for
>> > all error conditions, thus reducing code duplication.
>> 
>> Great!  This looks like I nice cleanup.  Will test it out.  Just a quick
>> comment based on the first glance:
>> 
>> >  outnl:
>> >  	return rv < 0 ? rv : count;
>> 
>> How about changing the single remaining error without any rewinding into
>> a direct "return -ENOMEM", and then drop the "outnl" label and simplify
>> this to "return count"?
>
> That would be the direct opposite of what this patch tries to do.
> Direct returns in a function with lock are not what I prefer to do.

OK.  I just noticed that you left the direct return just prior to this
one, after fixing up the error translation.

Anyway, the "outnl" is only ever used with rv < 0, and with your changes
all other cases where rv < 0 will jump to some other label.  So I don't
think it makes much sense to keep the "return rv < 0 ? rv : count" even
if you don't want the direct return.  Just move the "outnl" label
(possibly with a more describing name) down to the "return rv" at the
end.


I.e something like this:


bjorn@nemi:/usr/local/src/git/linux$ git diff
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index b78aa6f2a8c1..daa1ac300ac5 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -430,8 +430,7 @@ static ssize_t wdm_write
 
        usb_autopm_put_interface(desc->intf);
        mutex_unlock(&desc->wlock);
-outnl:
-       return rv < 0 ? rv : count;
+       return count;
 
 out_free_mem_pm:
        usb_autopm_put_interface(desc->intf);
@@ -439,6 +438,7 @@ out_free_mem_lock:
        mutex_unlock(&desc->wlock);
 out_free_mem:
        kfree(buf);
+outnl:
        return rv;
 }




Bjørn
--
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