From: "Rémi Denis-Courmont" <remi@remlab.net>
To: "Jason L Tibbitts III" <tibbs@math.uh.edu>
Cc: Sakari Ailus <sakari.ailus@iki.fi>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Hans Verkuil <hans.verkuil@cisco.com>,
linux-kernel@vger.kernel.org
Subject: Re: Commit 6016af "[media] v4l2: use __u32 rather than enums in ioctl() structs" breaks C++ users of V4L2
Date: Tue, 17 Jul 2012 07:39:35 +0300 [thread overview]
Message-ID: <201207170739.37176.remi@remlab.net> (raw)
In-Reply-To: <ufabojfv3ry.fsf@epithumia.math.uh.edu>
Le lundi 16 juillet 2012 23:40:01 Jason L Tibbitts III, vous avez écrit :
> I ran into problems compiling the program ZoneMinder on Fedora rawhide
> (currently using something around 3.5rc6) which do not appear with 3.4
> kernels. With help this was traced to commit
> 6016af82eafcb6e086a8f2a2197b46029a843d68, "[media] v4l2: use __u32
> rather than enums in ioctl() structs" which changed videodev2.h in a way
> which appears to be incompatible with C++.
>
> This results in code such as the following:
> enum v4l2_buf_type type = v4l2_data.fmt.type;
That code is dangerous, probably even more so in C++. If the running kernel
version is more recent than the kernel header version that userland was
compiled with, the field value could be outside the range of the enumeration.
> failing to compile with:
> zm_local_camera.cpp:1523:49: error: invalid conversion from '__u32
> {aka unsigned int}' to 'v4l2_buf_type' [-fpermissive]
> but only when compiled with the headers from a 3.5 kernel.
>
> I'm very far from a C++ expert. I talked with some people who do grok
> it and the issue comes down to restrictions on assignments of ints to
> enums
> and additionally that enums in C++ don't have defined size.
That cannot be true. Your C++ compiler must agree with the kernel's C compiler
on the size of enum. If they did not, V4L2 would not have ever worked from C++
code in previous kernel versions.
--
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis
prev parent reply other threads:[~2012-07-17 4:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 20:40 Commit 6016af "[media] v4l2: use __u32 rather than enums in ioctl() structs" breaks C++ users of V4L2 Jason L Tibbitts III
2012-07-17 4:39 ` Rémi Denis-Courmont [this message]
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=201207170739.37176.remi@remlab.net \
--to=remi@remlab.net \
--cc=hans.verkuil@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=sakari.ailus@iki.fi \
--cc=tibbs@math.uh.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox