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 <m...@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 --- a/configure.ac +++ b/configure.ac @@ -561,7 +561,15 @@ AM_ICONV dnl Checks for header files we can live without. AC_HEADER_STDC +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. +old_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Werror" AC_HEADER_MAJOR +CFLAGS=$old_CFLAGS AC_STRUCT_DIRENT_D_TYPE AC_CHECK_HEADERS(limits.h) diff --git a/lib/cpio.c b/lib/cpio.c index 57c9592..b7ba27d 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -9,9 +9,15 @@ #include "system.h" +/* system.h might already have included the wrong header, undef major + and minor and get the real definition from one of the correct headers. */ #if MAJOR_IN_MKDEV +#undef major +#undef minor #include <sys/mkdev.h> #elif MAJOR_IN_SYSMACROS +#undef major +#undef minor #include <sys/sysmacros.h> #else #include <sys/types.h> /* already included from system.h */ -- 1.8.3.1 _______________________________________________ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint