Linux-mediatek Archive on lore.kernel.org
 help / color / Atom feed
* usb: mtu3: Checking initialisation of the variable “mep” in two functions
@ 2020-06-27 12:28 Markus Elfring
  2020-06-29  1:48 ` Chunfeng Yun
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2020-06-27 12:28 UTC (permalink / raw)
  To: linux-mediatek, linux-usb, linux-arm-kernel, Chunfeng Yun,
	Greg Kroah-Hartman, Matthias Brugger
  Cc: Colin Ian King, kernel-janitors, LKML

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?

Regards,
Markus

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: usb: mtu3: Checking initialisation of the variable “mep” in two functions
  2020-06-27 12:28 usb: mtu3: Checking initialisation of the variable “mep” in two functions Markus Elfring
@ 2020-06-29  1:48 ` Chunfeng Yun
  0 siblings, 0 replies; 2+ messages in thread
From: Chunfeng Yun @ 2020-06-29  1:48 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors, LKML,
	linux-mediatek, Matthias Brugger, Colin Ian King,
	linux-arm-kernel

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

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-27 12:28 usb: mtu3: Checking initialisation of the variable “mep” in two functions Markus Elfring
2020-06-29  1:48 ` Chunfeng Yun

Linux-mediatek Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mediatek/0 linux-mediatek/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mediatek linux-mediatek/ https://lore.kernel.org/linux-mediatek \
		linux-mediatek@lists.infradead.org
	public-inbox-index linux-mediatek

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mediatek


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git