On Mon, 6 Nov 2006 22:28:37 +0100
Mariusz Kozlowski <[EMAIL PROTECTED]> wrote:
> Hello,
>
>
> In many places usb_(unlink,kill,free)_urb() are called this way:
>
> if (urb)
> usb_something_urb(...);
>
> which is not needed because functions like usb_unlink_urb() and
> usb_free_urb() are defined this way:
>
> void usb_free_urb(struct urb *urb)
> {
> if (urb)
> kref_put(&urb->kref, urb_destroy);
> }
>
> int usb_unlink_urb(struct urb *urb)
> {
> if (!urb)
> return -EINVAL;
> ...
> }
>
> We do not need to check for urb != NULL before we call them.
Seems reasonable.
Your patch had all its tabs replaced with spaces by your email client. I
fixed that all up, but it was rather dull work and I'd prefer not to have
to do it again.
It is also possible to do similar cleanup
> for usb_kill_urb(). The thing is it does urb check at the begining but right
> before is
> might_sleep():
>
> void usb_kill_urb(struct urb *urb)
> {
> might_sleep();
> if (!(urb && urb->dev && urb->dev->bus))
> return;
> ...
>
> which confuses me. I would like to know what to do about it. Can this be
> rewritten this way?:
>
> void usb_kill_urb(struct urb *urb)
> {
> if (!urb)
> return;
> might_sleep();
> if (!urb->dev || !urb->dev->bus))
> return;
> ...
>
> Or maybe there is no need for this?
>
I think it's OK as-is. Presumably it's rare for a caller to pass in a NULL
urb.
It's possible that your proposed change will cause new (and incorrect)
warnings to be emitted, but we can handle those if/when they come out.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel