From: Hans Verkuil <hverkuil@xs4all.nl>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: sparse and anonymous unions
Date: Sat, 15 Mar 2014 13:15:01 +0100 [thread overview]
Message-ID: <53244445.2000203@xs4all.nl> (raw)
In-Reply-To: <53242AC7.9080301@xs4all.nl>
Just for the linux-media mailinglist: I'm patching include/uapi/linux/v4l2-dv-timings.h
by adding ' || defined(__CHECKER__)' as described below during the sparse run of the
daily build for now. This gets rid of all these errors until I know whether this should
be a permanent patch or whether sparse will be fixed to handle this correctly.
Regards,
Hans
On 03/15/2014 11:26 AM, Hans Verkuil wrote:
> 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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2014-03-15 12:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-15 10:26 sparse and anonymous unions Hans Verkuil
2014-03-15 12:15 ` Hans Verkuil [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53244445.2000203@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.