Re: [RFC v3 1/2] v4l: Do not use enums in IOCTL structs

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

 



On Wed May 2 2012 23:39:15 Sakari Ailus wrote:
> Hi Hans,
> 
> On Wed, May 02, 2012 at 10:45:22PM +0200, Hans Verkuil wrote:
> > On Wed May 2 2012 21:13:47 Sakari Ailus wrote:
> > > Replace enums in IOCTL structs by __u32. The size of enums is variable and
> > > thus problematic. Compatibility structs having exactly the same as original
> > > definition are provided for compatibility with old binaries with the
> > > required conversion code.
> > 
> > Does someone actually have hard proof that there really is a problem? You know,
> > demonstrate it with actual example code?
> > 
> > It's pretty horrible that you have to do all those conversions and that code
> > will be with us for years to come.
> > 
> > For most (if not all!) architectures sizeof(enum) == sizeof(u32), so there is
> > no need for any compat code for those.
> 
> Cases I know where this can go wrong are, but there may well be others:
> 
> - ppc64: int is 64 bits there, and thus also enums,

Are you really, really certain that's the case? If I look at
arch/powerpc/include/asm/types.h it includes either asm-generic/int-l64.h
or asm-generic/int-ll64.h and both of those headers define u32 as unsigned int.
Also, if sizeof(int) != 4, then how would you define u32?

Ask a ppc64 kernel maintainer what sizeof(int) and sizeof(enum) are in the kernel
before we start doing lots of work for no reason.

Looking at arch/*/include/asm/types.h it seems all architectures define sizeof(int)
as 4.

What sizeof(long) is will actually differ between architectures, but char, short
and int seem to be fixed everywhere.

Regards,

	Hans

> 
> - Enums are quite a different concept in C++ than in C --- the compiler may
>   make assumpton based on the value range of the enums --- videodev2.h should
>   be included with extern "C" in that case, though,
> 
> - C does not specify which integer type enums actually use; this is what GCC
>   manual says about it:
> 
>   <URL:http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Enumerations>
> 
>   So a compiler other than GCC should use 16-bit enums and conform to C
>   while breaking V4L2. This might be a theoretical issue, though.
> 
> More discussion took place in this thread:
> 
> <URL:http://www.spinics.net/lists/linux-media/msg46167.html>
> 
> Regards,
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux