NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/38974: GCC designated initializers



>Number:         38974
>Category:       kern
>Synopsis:       GCC designated initializers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 18 01:50:00 +0000 2008
>Originator:     Gregory McGarry
>Release:        -current
>Organization:
>Environment:
>Description:
According to http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html, 
designated initializers with a range are a GCC extension and not part of c99.  
Increasingly, these are appearing in the NetBSD source tree and cause problems 
with c99 compilers.

One can be found in sys/dev/ic/ac97.c:

1.84         (christos 02-Sep-06): ac97_on_off = { 2, { { { AudioNoff, 0 } , 0 
},
1.84         (christos 02-Sep-06):                   { { AudioNon, 0 }  , 1 },
1.84         (christos 02-Sep-06):         [2 ... 31] = { { "", 0 }, 0 } } };

Maybe an explicit mention in KNF is needed?


>How-To-Repeat:
Compile NetBSD/i386 kernel using pcc.


>Fix:
Aren't uninitialised structure elements set to zero?  Maybe not for the kernel?

Index: ac97.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ac97.c,v
retrieving revision 1.87
diff -u -r1.87 ac97.c
--- ac97.c      8 Apr 2008 12:07:25 -0000       1.87
+++ ac97.c      18 Jun 2008 01:35:17 -0000
@@ -116,17 +116,104 @@
 static const struct audio_mixer_enum
 ac97_on_off = { 2, { { { AudioNoff, 0 } , 0 },
                     { { AudioNon, 0 }  , 1 },
-        [2 ... 31] = { { "", 0 }, 0 } } };
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 }, } };
 
 static const struct audio_mixer_enum
 ac97_mic_select = { 2, { { { AudioNmicrophone "0", 0  }, 0 },
                         { { AudioNmicrophone "1", 0  }, 1 },
-           [2 ... 31] = { { "", 0 }, 0 } } };
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 },
+                        { { "", 0 }    , 0 }, } };
 
 static const struct audio_mixer_enum
 ac97_mono_select = { 2, { { { AudioNmixerout, 0  }, 0 },
                          { { AudioNmicrophone, 0  }, 1 },
-            [2 ... 31] = { { "", 0 }, 0 } } };
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 },
+                         { { "", 0 }   , 0 }, } };
 
 static const struct audio_mixer_enum
 ac97_source = { 8, { { { AudioNmicrophone, 0  } , 0 },
@@ -137,7 +224,30 @@
                     { { AudioNmixerout, 0 }, 5 },
                     { { AudioNmixerout AudioNmono, 0 }, 6 },
                     { { Ac97Nphone, 0 }, 7 },
-       [8 ... 31] = { { "", 0 }, 0 } } };
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 },
+                    { { "", 0 }        , 0 }, } };
 
 /*
  * Due to different values for each source that uses these structures,




Home | Main Index | Thread Index | Old Index