usb/host/ohci-tmio.c:105: bad switch statement

2012-08-06 Thread David Binderman

Hello there,

I just ran the static analyser cppcheck over the source code of the
linux kernel version 3.6-rc1.

It said

linux-3.6-rc1/drivers/usb/host/ohci-tmio.c:105]: (warning) Redundant bitwise
operation on pm in switch

The source code is

switch (ohci-num_ports) {
default:
dev_err(dev-dev, Unsupported amount of ports: %d\n,
ohci-num_ports);
case 3:
pm |= CCR_PM_USBPW3;
case 2:
pm |= CCR_PM_USBPW2;
case 1:
pm |= CCR_PM_USBPW1;
}

Someone seems to have forgotten some break statements.
Suggest code rework.

Regards

David Binderman
  --
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb/host/ohci-tmio.c:105: bad switch statement

2012-08-06 Thread Alan Stern
On Mon, 6 Aug 2012, David Binderman wrote:

 
 Hello there,
 
 I just ran the static analyser cppcheck over the source code of the
 linux kernel version 3.6-rc1.
 
 It said
 
 linux-3.6-rc1/drivers/usb/host/ohci-tmio.c:105]: (warning) Redundant bitwise
 operation on pm in switch
 
 The source code is
 
 switch (ohci-num_ports) {
 default:
 dev_err(dev-dev, Unsupported amount of ports: %d\n,
 ohci-num_ports);
 case 3:
 pm |= CCR_PM_USBPW3;
 case 2:
 pm |= CCR_PM_USBPW2;
 case 1:
 pm |= CCR_PM_USBPW1;
 }
 
 Someone seems to have forgotten some break statements.
 Suggest code rework.

No, actually it looks like there's a typo in the macro definitions.  
Starting at line 60:

#define CCR_PM_USBPW10x0004
#define CCR_PM_USBPW20x0008
#define CCR_PM_USBPW30x0008

Probably that last one should 0x0010.  But I don't know, and most 
recent person listed as an author is Dmitry.

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html