[libvirt PATCH 19/32] src: conditionalize use of net/if.h

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

 



The net/if.h is not portable so we must check for its
existance and avoid using it when missing. Some use
of net/if.h was redundant and could be removed.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 build-aux/syntax-check.mk  | 2 +-
 configure.ac               | 1 +
 src/util/virnetdev.c       | 1 -
 src/util/virnetdev.h       | 4 +++-
 src/util/virnetdevbridge.c | 4 +++-
 src/util/virnetdevip.c     | 4 +++-
 src/util/virnetdevtap.c    | 4 +++-
 7 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index e5623606dd..7eb7d0beab 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -2338,4 +2338,4 @@ exclude_file_name_regexp--sc_prohibit_backslash_alignment = \
   ^build-aux/syntax-check\.mk$$
 
 exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
-  ^src/util/virfile\.c$$
+  ^src/util/(virfile|virnetdev|virnetdevip)\.[c,h]|$$
diff --git a/configure.ac b/configure.ac
index 855654c75d..75df326795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -381,6 +381,7 @@ AC_CHECK_HEADERS([\
   mntent.h \
   net/ethernet.h \
   netinet/tcp.h \
+  net/if.h \
   pty.h \
   pwd.h \
   stdarg.h \
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index b896a7507e..094d1ac09b 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -34,7 +34,6 @@
 #ifndef WIN32
 # include <sys/ioctl.h>
 #endif
-#include <net/if.h>
 #include <fcntl.h>
 
 #ifdef __linux__
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 24b41498ed..78e1aa656a 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -18,7 +18,9 @@
 
 #pragma once
 
-#include <net/if.h>
+#ifdef HAVE_NET_IF_H
+# include <net/if.h>
+#endif
 
 #include "virbitmap.h"
 #include "virsocketaddr.h"
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 5bb533f1f0..5a0fb5f42f 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -31,7 +31,9 @@
 # include <sys/ioctl.h>
 #endif
 #include <sys/socket.h>
-#include <net/if.h>
+#ifdef HAVE_NET_IF
+# include <net/if.h>
+#endif
 #include <netinet/in.h>
 
 #ifdef __linux__
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 5897c4aa76..bfb93cf258 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -36,7 +36,9 @@
 #ifndef WIN32
 # include <sys/ioctl.h>
 #endif
-#include <net/if.h>
+#ifdef HAVE_NET_IF_H
+# include <net/if.h>
+#endif
 #include <fcntl.h>
 
 #ifdef __linux__
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 8656e267cb..84d91428e7 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -36,7 +36,9 @@
 #ifndef WIN32
 # include <sys/ioctl.h>
 #endif
-#include <net/if.h>
+#ifdef HAVE_NET_IF
+# include <net/if.h>
+#endif
 #include <fcntl.h>
 #ifdef __linux__
 # include <linux/if_tun.h>    /* IFF_TUN, IFF_NO_PI */
-- 
2.24.1





[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]

  Powered by Linux