Kostiantyn Kostiuk wrote: > On Thu, Oct 15, 2026 at 8:33 PM Roman Bogorodskiy <[email protected]> > wrote: > > > 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 > > > > What is the difference? > > Before commit we check CONFIG_GETLOADAVG inside CONFIG_SOLARIS, so > this is definitly the same that you change CONFIG_GETLOADAVG > && CONFIG_SOLARIS
The whole include block looks like that: #ifdef HAVE_GETIFADDRS #include <arpa/inet.h> #include <sys/socket.h> #include <net/if.h> #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(CONFIG_SOLARIS) #include <net/if_arp.h> #include <netinet/if_ether.h> #if !defined(ETHER_ADDR_LEN) && defined(ETHERADDRL) #define ETHER_ADDR_LEN ETHERADDRL #endif #else #include <net/ethernet.h> #endif #ifdef CONFIG_SOLARIS #ifdef CONFIG_GETLOADAVG #include <sys/loadavg.h> #endif #include <sys/sockio.h> #endif #endif So if HAVE_GETIFADDRS is not defined, we do not include <sys/loadavg.h>, which we actually need even without HAVE_GETIFADDRS, as shown in the build error snippet in the commit message. So the patch fixes the build because it moves out this include outside of the "#ifdef HAVE_GETIFADDRS". "CONFIG_GETLOADAVG && CONFIG_SOLARIS" is a cosmetic change so we do not have 2 layers of checks just for a single header. > > Best Regards, > Kostiantyn Kostiuk. > > > > > #include <sys/sockio.h> > > #endif > > #endif > > -- > > 2.55.0 > > > >
