Make sure sys/types.h is included after sys/sysmacros.h

In the latest glibc, major() and minor() functions are marked as
deprecated (glibc commit dbab6577):

  CC       util/libvirt_util_la-vircgroup.lo
util/vircgroup.c: In function 'virCgroupGetBlockDevString':
util/vircgroup.c:768:5: error: '__major_from_sys_types' is deprecated:
  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 #undef it after including <sys/types.h>.
  [-Werror=deprecated-declarations]
     if (virAsprintf(&ret, "%d:%d ", major(sb.st_rdev), minor(sb.st_rdev)) < 0)
     ^~
In file included from /usr/include/features.h:397:0,
                 from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:28,
                 from ../gnulib/lib/stdio.h:43,
                 from util/vircgroup.c:26:
/usr/include/sys/sysmacros.h:87:1: note: declared here
 __SYSMACROS_DEFINE_MAJOR (__SYSMACROS_FST_IMPL_TEMPL)
 ^

Moreover, in the glibc commit, there's suggestion to keep
ordering of including of header files as implemented here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2016-09-06 14:20:04 +02:00
parent cbbaa17faf
commit f3f15cc240
5 changed files with 6 additions and 5 deletions

View File

@ -24,7 +24,6 @@
#include <config.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
@ -32,6 +31,8 @@
# include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include "domain_audit.h"
#include "viraudit.h"
#include "viruuid.h"

View File

@ -27,7 +27,6 @@
#include <sys/epoll.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/types.h>
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
@ -35,6 +34,7 @@
# include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include <sys/un.h>
#include <sys/personality.h>
#include <unistd.h>

View File

@ -28,7 +28,6 @@
#include <sched.h>
#include <sys/utsname.h>
#include <string.h>
#include <sys/types.h>
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
@ -36,6 +35,7 @@
# include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>

View File

@ -34,7 +34,6 @@
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
@ -42,6 +41,7 @@
# include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include <signal.h>
#include <dirent.h>
#include <unistd.h>

View File

@ -35,7 +35,6 @@
#include <errno.h>
#include <poll.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
@ -43,6 +42,7 @@
# include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include <sys/ioctl.h>
#include <string.h>
#include <termios.h>