Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbdHGQp0 (ORCPT ); Mon, 7 Aug 2017 12:45:26 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:37477 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbdHGQpY (ORCPT ); Mon, 7 Aug 2017 12:45:24 -0400 Date: Mon, 7 Aug 2017 09:45:05 -0700 From: "Darrick J. Wong" To: Arnd Bergmann Cc: Mikko Rapeli , Linux Kernel Mailing List , Linux API , "Theodore Ts'o" Subject: Re: [PATCH v06 33/36] uapi linux/fsmap.h: use __kernel_size_t instead of size_t Message-ID: <20170807164505.GC4474@magnolia> References: <20170806164428.2273-1-mikko.rapeli@iki.fi> <20170806164428.2273-34-mikko.rapeli@iki.fi> <20170807155445.GA4074@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2396 Lines: 61 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 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 > >> Cc: Darrick J. Wong > >> --- > >> 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 > > > > 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