[libvirt] [PATCH 10/12] src: add check for termios.h and conditionally include it

Daniel P. Berrangé berrange at redhat.com
Fri Jan 10 15:41:14 UTC 2020


The GNULIB termios module ensures termios.h exists, but
this is not neccessary and libvirt doesn't use any of its
functionality on platforms where it is missing. It is
thus sufficient to conditonallyinclude termios.h

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 configure.ac           | 1 +
 src/util/virfdstream.c | 4 +++-
 src/util/virfile.c     | 4 +++-
 src/util/virutil.c     | 1 -
 tools/virsh.h          | 1 -
 tools/vsh.h            | 4 +++-
 6 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3e5032a8c4..5e75688658 100644
--- a/configure.ac
+++ b/configure.ac
@@ -398,6 +398,7 @@ AC_CHECK_HEADERS([\
   sys/sysctl.h \
   sys/ucred.h \
   sys/un.h \
+  termios.h \
   ])
 dnl Check whether endian provides handy macros.
 AC_CHECK_DECLS([htole64], [], [], [[#include <endian.h>]])
diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index 719185d992..4d17dd0353 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -31,7 +31,9 @@
 # include <sys/un.h>
 #endif
 #include <netinet/in.h>
-#include <termios.h>
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
 
 #include "virfdstream.h"
 #include "virerror.h"
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 14bfd3beb6..0a743c8c3b 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -27,7 +27,9 @@
 
 #include <passfd.h>
 #include <fcntl.h>
-#include <termios.h>
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif /* !HAVE_TERMIOS_H */
 #ifdef HAVE_PTY_H
 /* Linux openpty */
 # include <pty.h>
diff --git a/src/util/virutil.c b/src/util/virutil.c
index beb890a7f4..6d1a914ae3 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -35,7 +35,6 @@
 #endif
 
 #include <sys/types.h>
-#include <termios.h>
 
 #if WITH_DEVMAPPER
 # include <libdevmapper.h>
diff --git a/tools/virsh.h b/tools/virsh.h
index 903a2e53b6..fa9e54b1d1 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -23,7 +23,6 @@
 #include <stdarg.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <termios.h>
 
 #include "internal.h"
 #include "virerror.h"
diff --git a/tools/vsh.h b/tools/vsh.h
index 960cae8df0..75272c2c97 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -23,7 +23,9 @@
 #include <stdarg.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <termios.h>
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
 
 #include "internal.h"
 #include "virerror.h"
-- 
2.24.1




More information about the libvir-list mailing list