[SeaBIOS] [PATCH] hw/usb-xhci.c: Code refactoring to not override initializers in `speed_from_xhci[16]`

Paul Menzel paulepanter at users.sourceforge.net
Thu Oct 3 12:09:27 CEST 2013


Date: Thu, 3 Oct 2013 11:55:48 +0200

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 at users.sourceforge.net>
---
 src/hw/usb-xhci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index 83eddc9..66ce3c4 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -277,11 +277,12 @@ static const char *speed_name[16] = {
 };
 
 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[] = {
-- 
1.8.4.rc3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.seabios.org/pipermail/seabios/attachments/20131003/73135ef9/attachment.sig>


More information about the SeaBIOS mailing list