Re: usb: mtu3: Checking initialisation of the variable âmepâ in two functions

From: Chunfeng Yun
Date: Sun Jun 28 2020 - 21:48:43 EST


Hi,
On Sat, 2020-06-27 at 14:28 +0200, Markus Elfring wrote:
> Hello,
>
> A source code analysis approach by the means of the semantic patch language
> (Coccinelle software) pointed an implementation detail out for further
> development considerations.
>
> The functions âmtu3_gadget_ep_set_haltâ and âmtu3_gadget_ep_set_wedgeâ check
> at the beginning if the input parameter âepâ is a null pointer.
> The error code â-EINVALâ will be returned then.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/mtu3/mtu3_gadget.c?id=1590a2e1c681b0991bd42c992cabfd380e0338f2#n371
> https://elixir.bootlin.com/linux/v5.7.2/source/drivers/usb/mtu3/mtu3_gadget.c#L371
>
> Can it be nicer to assign the variable âmepâ only after a successful check
> instead of an initialisation before?
Yes, I'll fix it, thanks a lot

>
> Regards,
> Markus