[Rpm-maint] [PATCH] config: Detect major/minor warnings and include the correct system header.
mark at klomp.org
Wed Jul 19 12:49:38 UTC 2017
glibc 2.25 introduced (really long and annoying) warnings for each use
of the major/minor macros from the wrong header:
lib/cpio.c: In function ‘rpmcpioHeaderWrite’:
lib/cpio.c:245:13: warning: In the GNU C Library, "major" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "major", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"major", you should undefine it after including <sys/types.h>.
dev = major(st->st_dev); SET_NUM_FIELD(hdr->devMajor, dev, field);
Adjust the configure check and undef the warning producing macros to get
rid of the wrong definitions and use the macros from the right include.
Tested against RHEL7 (glibc 2.17) and Fedora 26 (glibc 2.25).
Signed-off-by: Mark Wielaard <mark at klomp.org>
configure.ac | 8 ++++++++
lib/cpio.c | 6 ++++++
2 files changed, 14 insertions(+)
diff --git a/configure.ac b/configure.ac
index cc657ec..017a908 100644
@@ -561,7 +561,15 @@ AM_ICONV
dnl Checks for header files we can live without.
+dnl glibc and autoconf don't really play well together.
+dnl glibc will produce a warning when including the wrong header.
+dnl but still define major and minor. Causing us to include the header
+dnl that produces a giant warning for each major/minor use.
+dnl Use -Werror to work around that.
diff --git a/lib/cpio.c b/lib/cpio.c
index 57c9592..b7ba27d 100644
@@ -9,9 +9,15 @@
+/* system.h might already have included the wrong header, undef major
+ and minor and get the real definition from one of the correct headers. */
#include <sys/types.h> /* already included from system.h */
More information about the Rpm-maint