linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sparse and anonymous unions
@ 2014-03-15 10:26 Hans Verkuil
  2014-03-31  7:51 ` Hans Verkuil
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2014-03-15 10:26 UTC (permalink / raw)
  To: linux-sparse; +Cc: Linux Media Mailing List

Hi!

I'm trying to cut down the list of sparse warnings and errors I get when
compiling drivers/media. Most of them are obviously our problem, but there
is one that seems to be a sparse bug:

drivers/media/v4l2-core/v4l2-dv-timings.c:30:9: error: unknown field name in initializer

This uses the v4l2_dv_timings type which is defined here:

include/uapi/linux/videodev2.h

and which has an anonymous union:

struct v4l2_dv_timings {
        __u32 type;
        union {
                struct v4l2_bt_timings  bt;
                __u32   reserved[32];
        };
} __attribute__ ((packed));

The macro used in the source above comes from this header:

include/uapi/linux/v4l2-dv-timings.h

and is defined as follows:

#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
/* Sadly gcc versions older than 4.6 have a bug in how they initialize
   anonymous unions where they require additional curly brackets.
   This violates the C1x standard. This workaround adds the curly brackets
   if needed. */
#define V4L2_INIT_BT_TIMINGS(_width, args...) \
        { .bt = { _width , ## args } }
#else
#define V4L2_INIT_BT_TIMINGS(_width, args...) \
        .bt = { _width , ## args }
#endif

/* CEA-861-E timings (i.e. standard HDTV timings) */
        
#define V4L2_DV_BT_CEA_640X480P59_94 { \
        .type = V4L2_DV_BT_656_1120, \
        V4L2_INIT_BT_TIMINGS(640, 480, 0, 0, \
                25175000, 16, 96, 48, 10, 2, 33, 0, 0, 0, \
                V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, 0) \
}

The problem is that it seems that sparse follows the old pre-4.6 rules for
initializing anonymous unions instead of what is actually in the C standard.

If I add ' || defined(__CHECKER__)' to the #if above it will pass without
generating sparse errors.

Is this something that can be fixed in sparse, or am I forced to add the
'defined(__CHECKER__)' to the #if condition?

Regards,

	Hans

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-03 19:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-15 10:26 sparse and anonymous unions Hans Verkuil
2014-03-31  7:51 ` Hans Verkuil
2014-03-31  8:05   ` Hans Verkuil
2014-03-31 17:17   ` Linus Torvalds
2014-04-03 19:15     ` Christopher Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).