Re: Invalid Storage Class BUG

Alan Stern
2006-11-01T21:14:01Z

On Wed, 1 Nov 2006, Felipe Balbi wrote:

> Hello all,
>
> Could anyone help me fix this bug?
>
> I couldn't figure out what is happening.
>
> Here's the bug:
> drivers/usb/core/hub.c: In function 'usb_new_device':
> drivers/usb/core/hub.c:1293: error: invalid storage class for function
> '__usb_port_suspend'
> drivers/usb/core/hub.c:1294: warning: implicit declaration of function
> '__usb_port_suspend'
> drivers/usb/core/hub.c: At top level:
> drivers/usb/core/hub.c:1567: error: static declaration of
> '__usb_port_suspend' follows non-static declaration
> drivers/usb/core/hub.c:1294: error: previous implicit declaration of
> '__usb_port_suspend' was here
> make[3]: *** [drivers/usb/core/hub.o] Error 1
> make[2]: *** [drivers/usb/core] Error 2
> make[1]: *** [drivers/usb] Error 2
> make: *** [drivers] Error 2

Ho, ho!

Andrew, I _told_ you this inner declaration of a static function would
cause problems!

> Here's the source code:
>
> /* Maybe it can talk to us, though we can't talk to it.
> * (Includes HNP test device.)
> */
> if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
> static int __usb_port_suspend(struct usb_device *,
> int port1); * (line 1293)*
> err = __usb_port_suspend(udev,
> udev->bus->otg_port); * (line 1294)*
> if (err < 0)
> dev_dbg(&udev->dev, "HNP fail, %d\n", err);
> }
> err = -ENODEV;
> goto fail;
> }

The solution is simple. Just take line 1293 (the static function
declaration) and move it outside of the usb_new_device() function. Stick
it inside the "#ifdef CONFIG_USB_OTG" block just above the function's
start.

The problem is that gcc 4 doesn't like static function declarations in
inner blocks. Earlier versions of gcc didn't mind.

Alan Stern