NetBSD-Bugs archive

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

kern/39017: initialization of objects with static storage duration by compound literals



>Number:         39017
>Category:       kern
>Synopsis:       initialization of objects with static storage duration by 
>compound literals
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 22 12:20:00 +0000 2008
>Originator:     Gregory McGarry
>Release:        -current
>Organization:
>Environment:
>Description:
According to 
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Compound-Literals.html, ISO C99 
does not permit initialization of objects with static storage duration by 
compound literals.

However gcc has an extension which permits this.

umidi_quirks.h relies on this extension.

>How-To-Repeat:

>Fix:
This is how binary blobs have been included in static storage for ~25 years:

Index: umidi_quirks.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umidi_quirks.c,v
retrieving revision 1.15
diff -u -r1.15 umidi_quirks.c
--- umidi_quirks.c      28 Apr 2008 20:24:00 -0000      1.15
+++ umidi_quirks.c      22 Jun 2008 12:10:24 -0000
@@ -515,8 +515,8 @@
 };
 UMQ_DEF(MIDIMAN, MIDIMAN_MIDISPORT2X4, ANYIFACE) = {
        UMQ_FIXED_EP_REG(MIDIMAN, MIDIMAN_MIDISPORT2X4, ANYIFACE),
-       UMQ_CN_FIXED_REG(0, 2, 1, 3, 0, 1),
-       UMQ_MD_FIXED_REG(0, 0, 2, 1, 1, -1, 3, -1),
+       UMQ_CN_FIXED_REG("\0\2\1\3\0\1"),
+       UMQ_MD_FIXED_REG("\0\0\2\1\1\ff\3\ff"),
        UMQ_TYPE(MIDIMAN_GARBLE),
        UMQ_TERMINATOR
 };
Index: umidi_quirks.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umidi_quirks.h,v
retrieving revision 1.7
diff -u -r1.7 umidi_quirks.h
--- umidi_quirks.h      28 Apr 2008 20:24:00 -0000      1.7
+++ umidi_quirks.h      22 Jun 2008 12:10:25 -0000
@@ -108,13 +108,9 @@
  * in the same jack order implied by the FIXED_EP_DEF. Each value becomes
  * the cable number of the corresponding jack.
  */
-#if __STDC_VERSION__ >= 199901L
-#define UMQ_CN_FIXED_REG(...)                                          \
-{ .type=UMQ_TYPE_CN_FIXED, .data=(unsigned char[]){__VA_ARGS__} }
-#else /* assume gcc 2.95.3 */
-#define UMQ_CN_FIXED_REG(cns...)                                       \
-{ .type=UMQ_TYPE_CN_FIXED, .data=(unsigned char[]){cns} }
-#endif
+
+#define UMQ_CN_FIXED_REG(x)                                            \
+{ .type=UMQ_TYPE_CN_FIXED, .data=x }
 
 /*
  * quirk - fixed mididev assignment. Supply pairs of numbers out, in, as
@@ -125,13 +121,8 @@
  * Either out or in can be -1 to bind no out jack or in jack, respectively,
  * to the corresponding mididev.
  */
-#if __STDC_VERSION__ >= 199901L
-#define UMQ_MD_FIXED_REG(...)                                          \
-{ .type=UMQ_TYPE_MD_FIXED, .data=(unsigned char[]){__VA_ARGS__} }
-#else /* assume gcc 2.95.3 */
-#define UMQ_MD_FIXED_REG(mds...)                                       \
-{ .type=UMQ_TYPE_MD_FIXED, .data=(unsigned char[]){mds} }
-#endif
+#define UMQ_MD_FIXED_REG(x)                                            \
+{ .type=UMQ_TYPE_MD_FIXED, .data=x }
 
 /*
  * generic boolean quirk, no data




Home | Main Index | Thread Index | Old Index