A header file should include another header file if and only if
an there exists a symbol that requires the inclusion. For
instance, if a header file declares the following function:
int function(virDomainPtr dom);
then it is okay to have the header file include libvirt.h.
Unfortunately, some of our header files have needless includes.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/libvirtNotifications.h | 2 +-
src/libvirtSnmp.c | 2 ++
src/libvirtSnmp.h | 10 +++-------
src/libvirtSnmpError.c | 7 ++++++-
src/libvirtSnmpError.h | 3 ---
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/libvirtNotifications.h b/src/libvirtNotifications.h
index ee7a2e3..6c532b0 100644
--- a/src/libvirtNotifications.h
+++ b/src/libvirtNotifications.h
@@ -23,7 +23,7 @@
#ifndef __LIBVIRT_NOTIFICATIONS_H__
# define __LIBVIRT_NOTIFICATIONS_H__
-#include "libvirtSnmp.h"
+# include <libvirt/libvirt.h>
/*
* function declarations
diff --git a/src/libvirtSnmp.c b/src/libvirtSnmp.c
index 4ad6fab..3b5c17f 100644
--- a/src/libvirtSnmp.c
+++ b/src/libvirtSnmp.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <pthread.h>
#include <signal.h>
+#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
#include "libvirtSnmp.h"
#include "libvirtGuestTable.h" /* include our MIB structures*/
diff --git a/src/libvirtSnmp.h b/src/libvirtSnmp.h
index 2c5b0e5..24707bd 100644
--- a/src/libvirtSnmp.h
+++ b/src/libvirtSnmp.h
@@ -23,14 +23,10 @@
#ifndef __LIBVIRT_SNMP_H__
# define __LIBVIRT_SNMP_H__
-/* standard libvirt includes */
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
-
/* standard Net-SNMP includes */
-#include <net-snmp/net-snmp-config.h>
-#include <net-snmp/net-snmp-includes.h>
-#include <net-snmp/agent/net-snmp-agent-includes.h>
+# include <net-snmp/net-snmp-config.h>
+# include <net-snmp/net-snmp-includes.h>
+# include <net-snmp/agent/net-snmp-agent-includes.h>
/*
* Populate libvirtGuestTable into given container.
diff --git a/src/libvirtSnmpError.c b/src/libvirtSnmpError.c
index f5d546d..1678bcb 100644
--- a/src/libvirtSnmpError.c
+++ b/src/libvirtSnmpError.c
@@ -20,8 +20,13 @@
* Author: Michal Privoznik <mprivozn@redhat.com>
*/
-#include "libvirtSnmpError.h"
+#include <config.h>
+
#include <stdio.h>
+#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
+
+#include "libvirtSnmpError.h"
/**
* Print libvirt error
diff --git a/src/libvirtSnmpError.h b/src/libvirtSnmpError.h
index 6d59478..e28ad7c 100644
--- a/src/libvirtSnmpError.h
+++ b/src/libvirtSnmpError.h
@@ -23,9 +23,6 @@
#ifndef __LIBVIRT_SNMP_ERROR_H__
# define __LIBVIRT_SNMP_ERROR_H__
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
-
extern void printLibvirtError(const char *msg);
#endif /* __LIBVIRT_SNMP_ERROR_H__ */
--
2.18.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list