Re: [PATCH] media: do not use C++ style comments in uapi headers
From: Greg KH
Date: Wed Jun 05 2019 - 01:14:42 EST
On Wed, Jun 05, 2019 at 01:10:41PM +0900, Masahiro Yamada wrote:
> On Wed, Jun 5, 2019 at 3:21 AM Arnd Bergmann <arnd@xxxxxxxx> wrote:
> > > > >
> > > > > There are two ways to define fixed-width type.
> > > > >
> > > > > [1] #include <linux/types.h>, __u8, __u16, __u32, __u64
> > > > >
> > > > > vs
> > > > >
> > > > > [2] #include <stdint.h>, uint8_t, uint16_t, uint32_t, uint64_t
> > > > >
> > > > >
> > > > > Both are used in UAPI headers.
> > > > > IIRC, <stdint.h> was standardized by C99.
> > > > >
> > > > > So, we have already relied on C99 in user-space too.
> >
> > A related problem is that using the stdint.h types requires
> > including stdint.h first, but the C library requires that including
> > one standard header does not include another one recursively.
> >
> > So if sys/socket.h includes linux/socket.h, that must not include
> > stdint.h or any other header file that does so.
>
>
> This means we cannot reliably use uint{8,16,32,64}_t in UAPI headers.
We should not be doing that as they are in the userspace "namespace" of
variables, not in the kernel namespace. We've been over this many times
in the past :(
> [1] If we include <stdint.h> from linux/foo.h
>
> If sys/foo.h includes <linux/foo.h> and <stdint.h>,
> it violates the C library requirement.
>
>
> [2] If we do not include <stdint.h> from linux/foo.h
>
> If sys/foo.h includes <linux/foo.h>, but not <stdint.h>,
> we get 'unknown type name' errors.
We need to just use the proper __u{8,16,32,64} variable types instead,
that is exactly what they are there for.
thanks,
greg k-h