Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705713

Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead of size_t

From "Darrick J. Wong" <darrick.wong@oracle.com>
Newsgroups linux.kernel
Subject Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead of size_t
Date 2017-08-07 18:50 +0200
Message-ID <ubTo6-2M8-27@gated-at.bofh.it> (permalink)
References <ubxdT-50T-3@gated-at.bofh.it> <ubxnz-54r-5@gated-at.bofh.it> <ubSBJ-291-33@gated-at.bofh.it> <ubSLp-2uu-51@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Aug 07, 2017 at 06:01:43PM +0200, Arnd Bergmann wrote:
> On Mon, Aug 7, 2017 at 5:54 PM, Darrick J. Wong <darrick.wong@oracle.com> wrote:
> > On Sun, Aug 06, 2017 at 06:44:24PM +0200, Mikko Rapeli wrote:
> >> Fixes user space compilation error:
> >>
> >> linux/fsmap.h:71:19: error: unknown type name ‘size_t’
> >>  static __inline__ size_t
> >>                    ^~~~~~
> >>
> >> Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
> >> Cc: Darrick J. Wong <darrick.wong@oracle.com>
> >> ---
> >>  include/uapi/linux/fsmap.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/include/uapi/linux/fsmap.h b/include/uapi/linux/fsmap.h
> >> index 7e8e5f0bd6d2..99600bbed6b6 100644
> >> --- a/include/uapi/linux/fsmap.h
> >> +++ b/include/uapi/linux/fsmap.h
> >> @@ -68,7 +68,7 @@ struct fsmap_head {
> >>  };
> >>
> >>  /* Size of an fsmap_head with room for nr records. */
> >> -static inline size_t
> >> +static inline __kernel_size_t
> >
> > This is a static inline helper to assist in malloc calls.  We don't pass
> > size_t to the kernel, so why is this necessary over, say,
> >
> > #include <sys/types.h>
> >
> 
> Either way works, but including a system header from a kernel header
> requires an additional "#ifndef __KERNEL__" check, so I think Miko's
> variant is a little nicer.
> 
> Generally speaking, you also want to avoid including system headers
> indirectly from kernel headers, as POSIX requires that including one
> system header should not indirectly make symbols from other system
> headers visible. I think this is not a problem here though, as no system
> header should include linux/fsmap.h.

Sorry, I guess I was a little unclear about what I was asking -- I was
wondering why can't the userspace program include sys/types.h prior to
linux/fsmap.h?  I wasn't proposing including C library headers in kernel
headers.

I think the patch author is pushing towards kernel headers never relying
on /anything/ in the system headers.  For data structures being
exchanged with the kernel I agree, but the fsmap_sizeof result is never
passed to or received from the kernel; it exists purely for malloc
convenience.

--D

> 
>          Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v06 00/36] Userspace compile test and fixes for exported uapi header files Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:10 +0200
  [PATCH v06 16/36] uapi linux/dlm_netlink.h: include linux/dlmconstants.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:10 +0200
  [PATCH v06 34/36] uapi: break dependency loop between <linux/hdlc/ioctl.h> and <linux/if.h> Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:10 +0200
  [PATCH v06 12/36] x86 uapi asm/signal.h: use __kernel_size_t instead of size_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:10 +0200
    Re: [PATCH v06 12/36] x86 uapi asm/signal.h: use __kernel_size_t  instead of size_t Arnd Bergmann <arnd@arndb.de> - 2017-08-07 16:40 +0200
    Re: [PATCH v06 12/36] x86 uapi asm/signal.h: use __kernel_size_t  instead of size_t "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-09 01:00 +0200
  [PATCH v06 22/36] uapi linux/reiserfs_xattr.h: use __kernel_size_t instead of size_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:10 +0200
    Re: [PATCH v06 22/36] uapi linux/reiserfs_xattr.h: use  __kernel_size_t instead of size_t "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-09 01:20 +0200
      Re: [PATCH v06 05/36] uapi linux/sysctl.h: use __kernel_size_t  instead of size_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-09 09:30 +0200
  [PATCH v06 14/36] arm uapi asm/signal.h: include <stddef.h> for size_t in userspace Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:20 +0200
    Re: [PATCH v06 14/36] arm uapi asm/signal.h: include <stddef.h> for  size_t in userspace "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-09 01:00 +0200
      Re: [PATCH v06 14/36] arm uapi asm/signal.h: include <stddef.h> for  size_t in userspace Arnd Bergmann <arnd@arndb.de> - 2017-08-09 14:50 +0200
        Re: [PATCH v06 14/36] arm uapi asm/signal.h: include <stddef.h> for  size_t in userspace "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-09 15:00 +0200
  [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead of size_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:20 +0200
    Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t  instead of size_t "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-08-07 18:00 +0200
      Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead  of size_t Arnd Bergmann <arnd@arndb.de> - 2017-08-07 18:10 +0200
        Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t  instead of size_t "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-08-07 18:50 +0200
          Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead  of size_t Arnd Bergmann <arnd@arndb.de> - 2017-08-07 22:30 +0200
            Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t  instead of size_t "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-08-09 01:10 +0200
              Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead  of size_t Arnd Bergmann <arnd@arndb.de> - 2017-08-09 10:30 +0200
  [PATCH v06 01/36] Add scripts/headers_compile_test.sh: compile test for exported uapi headers Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:20 +0200
  [PATCH v06 20/36] uapi linux/scc.h: include linux/sockios.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:20 +0200
  [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in user space Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
    Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-08-06 22:30 +0200
      Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 23:00 +0200
    Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-08-06 22:30 +0200
      Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 23:00 +0200
        Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-08-06 23:30 +0200
          Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 23:40 +0200
            Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-08-06 23:50 +0200
              Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-07 00:00 +0200
                Re: [PATCH v06 18/36] uapi linux/errqueue.h: include linux/time.h in  user space Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-08-07 00:10 +0200
  [PATCH v06 36/36] uapi linux/kfd_ioctl.h: use __u32 and __u64 instead of uint32_t and uint64_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
    Re: [PATCH v06 36/36] uapi linux/kfd_ioctl.h: use __u32 and __u64  instead of uint32_t and uint64_t Arnd Bergmann <arnd@arndb.de> - 2017-08-07 17:10 +0200
  [PATCH v06 06/36] uapi asm-generic/ipcbuf.h: include linux/posix_types.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 17/36] uapi linux/sctp.h: use __u8, __u16 and __u32 from linux/types.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 07/36] uapi asm-generic/msgbuf.h: include asm/ipcbuf.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 25/36] uapi linux/android/binder.h: use __kernel_pid_t and __kernel_uid_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 02/36] uapi scsi/scsi_bsg_fc.h: use __u8, __u32 and __u64 from linux/types.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 11/36] uapi asm-generic/ucontext.h: include asm/signal.h and asm/sigcontext.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 10/36] uapi asm-generic/signal.h: use __kernel_size_t instead of size_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 24/36] uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 09/36] uapi asm-generic/sembuf.h: include asm/posix_types.h and asm/ipcbuf.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
    Re: [PATCH v06 09/36] uapi asm-generic/sembuf.h: include  asm/posix_types.h and asm/ipcbuf.h "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-09 00:50 +0200
  [PATCH v06 27/36] uapi xen/gntdev.h: include xen/privcmd.h and define grant_ref_t Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and in6.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
    Re: [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and  in6.h Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-08-09 01:20 +0200
      Re: [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and in6.h Moni Shoua <monis@mellanox.com> - 2017-08-09 15:50 +0200
        Re: [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and  in6.h Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-08-09 18:00 +0200
          Re: [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and  in6.h "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-10 04:50 +0200
            Re: [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and  in6.h Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-08-10 18:20 +0200
  [PATCH v06 13/36] x86 uapi asm/sembuf.h: include linux/types.h and linux/ipc.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
    Re: [PATCH v06 13/36] x86 uapi asm/sembuf.h: include linux/types.h  and linux/ipc.h "Dmitry V. Levin" <ldv@altlinux.org> - 2017-08-09 01:00 +0200
  [PATCH v06 26/36] uapi xen/privcmd.h: fix compilation in userspace Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200
  [PATCH v06 28/36] uapi xen/evtchn.h: include xen/privcmd.h Mikko Rapeli <mikko.rapeli@iki.fi> - 2017-08-06 19:30 +0200

csiph-web