Skip to contentSkip to conversation

major / minor macros are to be included from <sys/sysmacros.h>

PATCH In review Andreas Grapentin 2 participants 3 messages Mar 14, 2017

lore
Share & tools
lore
#0 lore raw

cover major / minor macros are to be included from <sys/sysmacros.h>

Building qemu fails with glibc-2.25 and gcc-6.3.1:

Quoted 8 lines

qemu/qga/commands-posix.c:656:13: error: 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>. [-Werror]

         *devmajor = major(st.st_rdev);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~

A trivial fix is to #include <sys/sysmacros.h> in the respective files.

Andreas Grapentin (1):
major / minor macros are to be included from <sys/sysmacros.h>

 hw/9pfs/9p.c         | 1 +
 qga/commands-posix.c | 1 +
 2 files changed, 2 insertions(+)
Signature · 1 line
2.12.0
#1 lore raw

PATCH 1/1 major / minor macros are to be included from <sys/sysmacros.h>

---
 hw/9pfs/9p.c         | 1 +
 qga/commands-posix.c | 1 +
 2 files changed, 2 insertions(+)
hw/9pfs/9p.c +1 -0
index 76c9247c77..d9cfa8900e 100644
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include <sys/sysmacros.h>
 #include <glib/gprintf.h>
 #include "hw/virtio/virtio.h"
 #include "qapi/error.h"
qga/commands-posix.c +1 -0
index 73d93eb5ce..9eecdd092c 100644
@@ -14,6 +14,7 @@
 #include "qemu/osdep.h"
 #include <sys/ioctl.h>
 #include <sys/wait.h>
+#include <sys/sysmacros.h>
 #include <dirent.h>
 #include "qga/guest-agent-core.h"
 #include "qga-qmp-commands.h"
Signature · 1 line
2.12.0
#2 lore raw
In reply to Andreas Grapentin
Quoted 11 lines · Andreas Grapentin

Building qemu fails with glibc-2.25 and gcc-6.3.1:

Quoted 8 lines

qemu/qga/commands-posix.c:656:13: error: 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>. [-Werror]

         *devmajor = major(st.st_rdev);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 5 lines

A trivial fix is to #include <sys/sysmacros.h> in the respective files.

Andreas Grapentin (1):
major / minor macros are to be included from <sys/sysmacros.h>

NACK. <sys/sysmacros.h> is not a universal file, so you can't blindly include it without first checking that it exists. We already fixed the problem correctly in commit 4d04351, which just landed today.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org