Using Debian clang version 3.4-1 (trunk) (based on LLVM 3.4) to build
SeaBIOS, the switch `-Winitializer-overrides` results in the following
warnings.
$ CC=clang make
[…]
Compile checking out/src/hw/usb-xhci.o
clang: warning: argument unused during compilation: '-mpreferred-stack-boundary=2'
clang: warning: argument unused during compilation: '-minline-all-stringops'
clang: warning: argument unused during compilation: '-fno-delete-null-pointer-checks'
src/hw/usb-xhci.c:281:13: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
[ 1 ] = USB_FULLSPEED,
^~~~~~~~~~~~~
src/hw/usb.h:68:24: note: expanded from macro 'USB_FULLSPEED'
^
src/hw/usb-xhci.c:280:20: note: previous initialization is here
[ 0 ... 15 ] = -1,
^~
src/hw/usb-xhci.c:282:13: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
[ 2 ] = USB_LOWSPEED,
^~~~~~~~~~~~
src/hw/usb.h:69:24: note: expanded from macro 'USB_LOWSPEED'
^
src/hw/usb-xhci.c:280:20: note: previous initialization is here
[ 0 ... 15 ] = -1,
^~
src/hw/usb-xhci.c:283:13: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
[ 3 ] = USB_HIGHSPEED,
^~~~~~~~~~~~~
src/hw/usb.h:70:24: note: expanded from macro 'USB_HIGHSPEED'
^
src/hw/usb-xhci.c:280:20: note: previous initialization is here
[ 0 ... 15 ] = -1,
^~
src/hw/usb-xhci.c:284:13: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
[ 4 ] = USB_SUPERSPEED,
^~~~~~~~~~~~~~
src/hw/usb.h:71:24: note: expanded from macro 'USB_SUPERSPEED'
^
src/hw/usb-xhci.c:280:20: note: previous initialization is here
[ 0 ... 15 ] = -1,
^~
Refactor the code a little to get rid of the warnings.
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
};
static const int speed_from_xhci[16] = {
- [ 0 ... 15 ] = -1,
+ [ 0 ] = -1,
[ 1 ] = USB_FULLSPEED,
[ 2 ] = USB_LOWSPEED,
[ 3 ] = USB_HIGHSPEED,
[ 4 ] = USB_SUPERSPEED,
+ [ 5 ... 15 ] = -1,
};
static const int speed_to_xhci[] = {