RE: [PATCH v3 2/2] usb: dwc2: gadget: modify return statement

From: Paul Zimmerman
Date: Fri Oct 17 2014 - 14:11:03 EST


> From: Sudip Mukherjee [mailto:sudipm.mukherjee@xxxxxxxxx]
> Sent: Friday, October 17, 2014 3:03 AM
>
> On Fri, Oct 17, 2014 at 09:02:00AM +0000, David Laight wrote:
> > From: Of Sudip Mukherjee
> > > modified the function to have a single return statement at the end
> > > instead of multiple return statement in the middle of the function
> > > to improve the readability of the code.
> >
> > Many of us would disagree with you there.
> > Early returns actually make the code easier to read, certainly
> > better than a goto 'end of function'.
> >
> actually , frankly speaking, this first return statement was also easier for me to understand. But in
> my v1 patch , Paul mentioned :
> >For a long function like this, I'd rather keep a single return point at
> >the end.
> so I thought he meant all the return statements in the function.

What I didn't like about your first patch was that there were two
places where the spinlock was released. I think that is error-prone,
as can be seen by the original bug. But I am OK with leaving the
first return statement as-is, since the spinlock is not held there.

So I think we should apply patch 1, and drop patch 2.

--
Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/