[PATCH 2/2] sys_types: avoid glibc 2.25 warnings about major()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Todo: tweak sys_types_h.m4 comment before pushing

glibc 2.25 is deprecating the namespace pollution of <sys/types.h>
injecting major(), minor(), and makedev() into the compilation
environment, with a warning that insists that users include
<sys/sysmacros.h> instead.  However, because the expansion of
AC_HEADER_MAJOR didn't bother checking sys/sysmacros.h until
after probing whether sys/types.h pollutes the namespace, it was
not defining MAJOR_IN_SYSMACROS, with the result that code
compiled with -Werror chokes on the deprecation warnings because
it was not including sysmacros.h.

Backport the autoconf fix, so that gnulib projects avoid the
warnings even when using older autoconf.

* m4/sys_types_h.m4 (AC_HEADER_MAJOR): Replace broken version in
older autoconf.
* doc/posix-headers/sys_types.texi (sys/types.h): Document fix.
* doc/glibc-functions/gnu_dev_major.texi (gnu_dev_major): Likewise.
* doc/glibc-functions/gnu_dev_makedev.texi (gnu_dev_makedev): Likewise.
* doc/glibc-functions/gnu_dev_minor.texi (gnu_dev_minor): Likewise.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---

Obviously, I'll be tweaking this slightly to list an actual
commit id that gets pushed to autoconf, but posting now for
review.

 ChangeLog                                |  8 ++++++++
 doc/glibc-functions/gnu_dev_major.texi   |  4 ++++
 doc/glibc-functions/gnu_dev_makedev.texi |  4 ++++
 doc/glibc-functions/gnu_dev_minor.texi   |  4 ++++
 doc/posix-headers/sys_types.texi         |  6 ++++++
 m4/sys_types_h.m4                        | 27 ++++++++++++++++++++++++++-
 6 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index ae0816d..1e694e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2016-09-14  Eric Blake  <eblake@xxxxxxxxxx>

+	sys_types: avoid glibc 2.25 warnings about major()
+	* m4/sys_types_h.m4 (AC_HEADER_MAJOR): Replace broken version in
+	older autoconf.
+	* doc/posix-headers/sys_types.texi (sys/types.h): Document fix.
+	* doc/glibc-functions/gnu_dev_major.texi (gnu_dev_major): Likewise.
+	* doc/glibc-functions/gnu_dev_makedev.texi (gnu_dev_makedev): Likewise.
+	* doc/glibc-functions/gnu_dev_minor.texi (gnu_dev_minor): Likewise.
+
 	mountlist: include sysmacros.h for glibc
 	* m4/mountlist.m4 (gl_PREREQ_MOUTLIST_EXTRA): Include
 	AC_HEADER_MAJOR.
diff --git a/doc/glibc-functions/gnu_dev_major.texi b/doc/glibc-functions/gnu_dev_major.texi
index f7a2cfd..3a85300 100644
--- a/doc/glibc-functions/gnu_dev_major.texi
+++ b/doc/glibc-functions/gnu_dev_major.texi
@@ -6,6 +6,10 @@ gnu_dev_major

 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/gnu_dev_makedev.texi b/doc/glibc-functions/gnu_dev_makedev.texi
index febd7f8..2738698 100644
--- a/doc/glibc-functions/gnu_dev_makedev.texi
+++ b/doc/glibc-functions/gnu_dev_makedev.texi
@@ -6,6 +6,10 @@ gnu_dev_makedev

 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/gnu_dev_minor.texi b/doc/glibc-functions/gnu_dev_minor.texi
index a3dbefe..b4c789c 100644
--- a/doc/glibc-functions/gnu_dev_minor.texi
+++ b/doc/glibc-functions/gnu_dev_minor.texi
@@ -6,6 +6,10 @@ gnu_dev_minor

 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/doc/posix-headers/sys_types.texi b/doc/posix-headers/sys_types.texi
index 29bb9ae..cf44bea 100644
--- a/doc/posix-headers/sys_types.texi
+++ b/doc/posix-headers/sys_types.texi
@@ -19,6 +19,12 @@ sys/types.h
 @item
 The type @code{mode_t} is not defined on some platforms:
 MSVC 9.
+@item
+Some systems leak definitions of @code{major}, @code{minor}, and
+@code{makedev} through this header; however, when
+@file{sys/sysmacros.h} exists, that file should also be included to
+avoid deprecation warnings from the versions in this header:
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4
index b0aabb4..64be679 100644
--- a/m4/sys_types_h.m4
+++ b/m4/sys_types_h.m4
@@ -1,4 +1,4 @@
-# sys_types_h.m4 serial 5
+# sys_types_h.m4 serial 6
 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -22,3 +22,28 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
 AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
 [
 ])
+
+# This works around a buggy version in autoconf <= 2.69.
+# See <https://lists.gnu.org/archive/html/autoconf/2016-08/msg00014.html>
+
+m4_version_prereq([2.70], [], [
+
+# This is taken from the following Autoconf patch:
+# http://git.sv.gnu.org/cgit/autoconf.git/commit/?id=XXXXXXX
+
+m4_undefine([AC_HEADER_MAJOR])
+AC_DEFUN([AC_HEADER_MAJOR],
+[AC_CHECK_HEADERS_ONCE([sys/types.h])
+AC_CHECK_HEADER([sys/mkdev.h],
+  [AC_DEFINE([MAJOR_IN_MKDEV], [1],
+    [Define to 1 if `major', `minor', and `makedev' are declared in
+     <mkdev.h>.])])
+if test $ac_cv_header_sys_mkdev_h = no; then
+  AC_CHECK_HEADER([sys/sysmacros.h],
+    [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
+      [Define to 1 if `major', `minor', and `makedev' are declared in
+       <sysmacros.h>.])])
+fi
+])
+
+])
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]