Currently, build fails on illumos with:

../qga/commands-posix.c: In function 'qmp_guest_get_load':
../qga/commands-posix.c:1408:9: error: implicit declaration of function 
'getloadavg' [-Wimplicit-function-declaration]
 1408 |     if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
      |         ^~~~~~~~~~
../qga/commands-posix.c:1408:9: warning: nested extern declaration of 
'getloadavg' [-Wnested-externs]

This happens because including <sys/loadavg.h> which is needed
for getloadavg() on illumos is nested under the "#ifdef HAVE_GETIFADDRS"
block, and is not included when HAVE_GETIFADDRS is not defined.

As getloadavg() does not depend on HAVE_GETIFADDRS, include
<sys/loadavg.h> outside of the "#ifdef HAVE_GETIFADDRS".

Signed-off-by: Roman Bogorodskiy <[email protected]>
---
 qga/commands-posix.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 837e285b6d..f58169b43e 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -16,6 +16,9 @@
 #include <sys/utsname.h>
 #include <sys/wait.h>
 #include <dirent.h>
+#if defined(CONFIG_SOLARIS) && defined(CONFIG_GETLOADAVG)
+#include <sys/loadavg.h>
+#endif
 #include "qga-qapi-commands.h"
 #include "qapi/error.h"
 #include "qemu/host-utils.h"
@@ -43,9 +46,6 @@
 #include <net/ethernet.h>
 #endif
 #ifdef CONFIG_SOLARIS
-#ifdef CONFIG_GETLOADAVG
-#include <sys/loadavg.h>
-#endif
 #include <sys/sockio.h>
 #endif
 #endif
-- 
2.55.0


Reply via email to