Pádraig Brady wrote:
> I notice coreutils CI now failing with:
> 
>    In file included from lib/readutmp.c:47:
>    /usr/include/x86_64-linux-gnu/sys/sysctl.h:21:2: error:
>    #warning "The <sys/sysctl.h> header is deprecated and will be removed." 
> [-Werror=cpp]
>     21 | #warning "The <sys/sysctl.h> header is deprecated and will be 
> removed."
>        |  ^~~~~~~
> 
> This deprecation of sysctl on glibc >= 2.30 was dealt with in coreutils 
> before like:
> https://github.com/coreutils/coreutils/commit/18c938280
> Perhaps we should avoid this fallback similarly if defined __GLIBC__ ?

I see. Thanks; I did not know about this #warning.

'#if defined __GLIBC__' is not right, because it disables the use of the
sysctl call also on GNU/kFreeBSD. Per glibc commit
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=076f09afbac1aa57756faa7a8feadb7936a724e4
the right condition to use is '#if defined __GLIBC__ && defined __linux__'.

This patch fixes it. Tested on Fedora 31 (glibc 2.30) and openSUSE 15.5 (glibc 
2.31).


2023-08-13  Bruno Haible  <br...@clisp.org>

        readutmp, boot-time: Fix warning on glibc 2.30..2.31 on Linux.
        Reported by Pádraig Brady in
        <https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00110.html>.
        * lib/readutmp.c: Don't include <sys/sysctl.h> on glibc/Linux.
        * lib/boot-time.c: Likewise.

diff --git a/lib/boot-time.c b/lib/boot-time.c
index c359954f19..fe5b5b88c8 100644
--- a/lib/boot-time.c
+++ b/lib/boot-time.c
@@ -32,7 +32,7 @@
 # include <time.h>
 #endif
 
-#if HAVE_SYS_SYSCTL_H && !defined __minix
+#if HAVE_SYS_SYSCTL_H && !(defined __GLIBC__ && defined __linux__) && !defined 
__minix
 # if HAVE_SYS_PARAM_H
 #  include <sys/param.h>
 # endif
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 0b7732b165..7967db60a8 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -40,7 +40,7 @@
 # include <systemd/sd-login.h>
 #endif
 
-#if HAVE_SYS_SYSCTL_H && !defined __minix
+#if HAVE_SYS_SYSCTL_H && !(defined __GLIBC__ && defined __linux__) && !defined 
__minix
 # if HAVE_SYS_PARAM_H
 #  include <sys/param.h>
 # endif




Reply via email to