Subject: Re: [PATCH] devlink: fix libc and kernel headers collision

From: Stephen Hemminger <[email-masked]>
Date: Tue, 4 Jun 2019 09:47:18 -0700

On Thu, 30 May 2019 18:32:27 +0300
Baruch Siach <[email-masked]> wrote:

> Since commit 2f1242efe9d ("devlink: Add devlink health show command") we
> use the sys/sysinfo.h header for the sysinfo(2) system call. But since
> iproute2 carries a local version of the kernel struct sysinfo, this
> causes a collision with libc that do not rely on kernel defined sysinfo
> like musl libc:
> 
> In file included from devlink.c:25:0:
> .../sysroot/usr/include/sys/sysinfo.h:10:8: error: redefinition of 'struct sysinfo'
>  struct sysinfo {
>         ^~~~~~~
> In file included from ../include/uapi/linux/kernel.h:5:0,
>                  from ../include/uapi/linux/netlink.h:5,
>                  from ../include/uapi/linux/genetlink.h:6,
>                  from devlink.c:21:
> ../include/uapi/linux/sysinfo.h:8:8: note: originally defined here
>  struct sysinfo {
> 		^~~~~~~
> 
> Rely on the kernel header alone to avoid kernel and userspace headers
> collision of definitions.
> 
> Cc: Aya Levin <[email-masked]>
> Cc: Moshe Shemesh <[email-masked]>
> Signed-off-by: Baruch Siach <[email-masked]>

Sorry this breaks the glibc build.

    CC       devlink.o
devlink.c: In function ‘format_logtime’:
devlink.c:6124:8: warning: implicit declaration of function ‘sysinfo’; did you mean ‘psiginfo’? [-Wimplicit-function-declaration]
  err = sysinfo(&s_info);
        ^~~~~~~
        psiginfo

I backed out the patch now (before pushing it).
Please fix and resubmit.