[PATCH 1/1] staging: rtl8188eu: usb_dvobj_init(): A NULL pointer check for usb_host_endpoints makes no sense
From: Jes Sorensen struct usb_host_interface points to an array of struct usb_host_endpoints - it makes no sense to do a NULL pointer check for each pointer. Signed-off-by: Jes Sorensen --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 33 + 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 65a257f..2b5ee2d 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -62,7 +62,6 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_config_descriptor*pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; - struct usb_host_endpoint*phost_endp; struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; @@ -91,24 +90,22 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { int ep_num; - phost_endp = phost_iface->endpoint + i; - - if (phost_endp) { - pendp_desc = &phost_endp->desc; - ep_num = usb_endpoint_num(pendp_desc); - - if (usb_endpoint_is_bulk_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_int_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_bulk_out(pendp_desc)) { - pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; - pdvobjpriv->RtNumOutPipes++; - } - pdvobjpriv->ep_num[i] = ep_num; + pendp_desc = &phost_iface->endpoint[i].desc; + + ep_num = usb_endpoint_num(pendp_desc); + + if (usb_endpoint_is_bulk_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_int_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = + ep_num; + pdvobjpriv->RtNumOutPipes++; } + pdvobjpriv->ep_num[i] = ep_num; } if (pusbd->speed == USB_SPEED_HIGH) -- 1.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/1] staging: rtl8188eu: usb_dvobj_init(): A NULL pointer check for usb_host_endpoints makes no sense
On 12/01/2014 02:20 PM, jes.soren...@redhat.com wrote: From: Jes Sorensen struct usb_host_interface points to an array of struct usb_host_endpoints - it makes no sense to do a NULL pointer check for each pointer. Signed-off-by: Jes Sorensen --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 33 + 1 file changed, 15 insertions(+), 18 deletions(-) Acked-by: Larry Finger Thanks for porting your changes found in one of the Realtek drivers. Larry diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 65a257f..2b5ee2d 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -62,7 +62,6 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_config_descriptor*pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; - struct usb_host_endpoint*phost_endp; struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; @@ -91,24 +90,22 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { int ep_num; - phost_endp = phost_iface->endpoint + i; - - if (phost_endp) { - pendp_desc = &phost_endp->desc; - ep_num = usb_endpoint_num(pendp_desc); - - if (usb_endpoint_is_bulk_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_int_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_bulk_out(pendp_desc)) { - pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; - pdvobjpriv->RtNumOutPipes++; - } - pdvobjpriv->ep_num[i] = ep_num; + pendp_desc = &phost_iface->endpoint[i].desc; + + ep_num = usb_endpoint_num(pendp_desc); + + if (usb_endpoint_is_bulk_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_int_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = + ep_num; + pdvobjpriv->RtNumOutPipes++; } + pdvobjpriv->ep_num[i] = ep_num; } if (pusbd->speed == USB_SPEED_HIGH) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel