Missing size_t declaration in UAPI
Commit Message
Hi, I want to continue that discussion
I see three options to resolve this:
1. Add `#include <stddef.h>` in every header that uses `size_t` (patch
provided).
2. Add `#include <stddef.h>` to `asm-generic/posix_types.h` and make
sure every header that uses `size_t` will include that.
3. Replace all usages of `size_t` with `__kernel_size_t`.
Included a patch for the first option but if people prefer I'll
provide patches for the rest.
I never contributed code to linux so feedback on your thoughts and the
process are more than welcome :)
```
```
On Sun, Nov 10, 2019 at 11:36 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Elichai Turkel:
>
> >>>> <stddef.h> is expected to be provided by the compiler. It's probably
> >>>> easier to fix your build environment.
> >
> > `<stddef.h>` is obviously *provided* by the compiler. but it's still
> > need to be *included*.
> > so maybe I'm going too far and we just need to include `<stddef.h>` in
> > `linux/types.h`.
>
> Yes, that should work. <linux/types.h> obviously must be compatible
> with <stddef.h>.
@@ -52,7 +52,7 @@
#ifndef __KERNEL__
#include <linux/types.h>
-#include <stdlib.h>
+#include <stddef.h>
struct agp_version {
__u16 major;
@@ -2,6 +2,10 @@
#ifndef __LINUX_ARCFB_H__
#define __LINUX_ARCFB_H__
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
#define FBIO_WAITEVENT _IO('F', 0x88)
#define FBIO_GETCONTROL2 _IOR('F', 0x89, size_t)
@@ -97,6 +97,7 @@ typedef unsigned long long u_quad_t;
#include <linux/time.h>
#define cdev_t u_quad_t
#ifndef __KERNEL__
+#include <stddef.h>
#if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
#define _UQUAD_T_ 1
typedef unsigned long long u_quad_t;
@@ -15,6 +15,7 @@
#include <linux/types.h>
#ifndef __KERNEL__
#include <linux/fscrypt.h>
+#include <stddef.h>
#endif
/* Use of MS_* flags within the kernel is restricted to core mount(2) code. */
@@ -10,6 +10,9 @@
#define _LINUX_FSMAP_H
#include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
/*
* Structure for FS_IOC_GETFSMAP.
@@ -18,6 +18,10 @@
#ifndef _LINUX_I8K_H
#define _LINUX_I8K_H
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
#define I8K_PROC "/proc/i8k"
#define I8K_PROC_FMT "1.0"
@@ -28,6 +28,10 @@
#include <linux/in.h>
#include <linux/in6.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
/* For user-space programs to pick up these definitions
* which they wouldn't get otherwise without defining __KERNEL__
*/
@@ -8,6 +8,9 @@
*/
#include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
/* kexec flags for different usage scenarios */
#define KEXEC_ON_CRASH 0x00000001
@@ -47,6 +50,7 @@
#define KEXEC_SEGMENT_MAX 16
#ifndef __KERNEL__
+#include <stddef.h>
/*
* This structure is used to hold the arguments that are used when
* loading kernel binaries.
@@ -7,6 +7,10 @@
#include <linux/videodev2.h>
#include <linux/fb.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
struct matroxioc_output_mode {
__u32 output; /* which output */
#define MATROXFB_OUTPUT_PRIMARY 0x0000
@@ -23,6 +23,9 @@
#include <linux/types.h>
#include <linux/socket.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
#define NFC_GENL_NAME "nfc"
#define NFC_GENL_VERSION 1
@@ -28,6 +28,9 @@
#include <linux/fb.h>
#include <linux/ioctl.h>
#include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
/* IOCTL commands. */
@@ -122,6 +122,9 @@ enum {
* Ioctl commands for the /dev/pmu device
*/
#include <linux/ioctl.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
/* no param */
#define PMU_IOC_SLEEP _IO('B', 0)
@@ -4,6 +4,9 @@
#include <asm/ioctl.h>
#include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
#define ATY_RADEON_LCD_ON 0x00000001
#define ATY_RADEON_CRT_ON 0x00000002
b/include/uapi/linux/reiserfs_xattr.h
@@ -7,6 +7,9 @@
#define _LINUX_REISERFS_XATTR_H
#include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
/* Magic value in header */
#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
b/include/uapi/linux/seg6_iptunnel.h
@@ -16,6 +16,9 @@
#define _UAPI_LINUX_SEG6_IPTUNNEL_H
#include <linux/seg6.h> /* For struct ipv6_sr_hdr. */
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
enum {
SEG6_IPTUNNEL_UNSPEC,
@@ -26,6 +26,9 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/compiler.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
#define CTL_MAXNAME 10 /* how many path components do we allow in a
call to sysctl? In other words, what is
@@ -38,6 +38,10 @@
#include <linux/compiler.h>
#include <xen/interface/xen.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
struct privcmd_hypercall {
__u64 op;
__u64 arg[5];