Use the ATTRIBUTE_NONNULL annotation to mark some virConnectPtr args as mandatory non-null so the compiler can warn of mistakes * src/conf/domain_event.h: All virConnectPtr args must be non-null * src/qemu/qemu_conf.h: qemudBuildCommandLine and qemudNetworkIfaceConnect() must be given non-null connection * tests/qemuxml2argvtest.c: Provide a non-null (dummy) connection to qemudBuildCommandLine() --- src/conf/domain_event.h | 13 +++++++++---- src/qemu/qemu_conf.h | 6 ++++-- tests/qemuxml2argvtest.c | 8 +++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h index f29e42e..aa0346b 100644 --- a/src/conf/domain_event.h +++ b/src/conf/domain_event.h @@ -50,18 +50,23 @@ int virDomainEventCallbackListAdd(virConnectPtr conn, virDomainEventCallbackListPtr cbList, virConnectDomainEventCallback callback, void *opaque, - virFreeCallback freecb); + virFreeCallback freecb) + ATTRIBUTE_NONNULL(1); int virDomainEventCallbackListRemove(virConnectPtr conn, virDomainEventCallbackListPtr cbList, - virConnectDomainEventCallback callback); + virConnectDomainEventCallback callback) + ATTRIBUTE_NONNULL(1); int virDomainEventCallbackListRemoveConn(virConnectPtr conn, - virDomainEventCallbackListPtr cbList); + virDomainEventCallbackListPtr cbList) + ATTRIBUTE_NONNULL(1); int virDomainEventCallbackListMarkDelete(virConnectPtr conn, virDomainEventCallbackListPtr cbList, - virConnectDomainEventCallback callback); + virConnectDomainEventCallback callback) + ATTRIBUTE_NONNULL(1); + int virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList); /** diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 5c41a1a..d26bb90 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -188,7 +188,8 @@ int qemudBuildCommandLine (virConnectPtr conn, const char ***retenv, int **tapfds, int *ntapfds, - const char *migrateFrom); + const char *migrateFrom) + ATTRIBUTE_NONNULL(1); /* With vlan == -1, use netdev syntax, else old hostnet */ char * qemuBuildHostNetStr(virDomainNetDefPtr net, @@ -241,7 +242,8 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev); int qemudNetworkIfaceConnect (virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - unsigned long long qemuCmdFlags); + unsigned long long qemuCmdFlags) + ATTRIBUTE_NONNULL(1); int qemudProbeMachineTypes (const char *binary, virCapsGuestMachinePtr **machines, diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8bdab49..3ee71a3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -13,6 +13,7 @@ #include "internal.h" #include "testutils.h" #include "qemu/qemu_conf.h" +#include "datatypes.h" #include "testutilsqemu.h" @@ -36,6 +37,10 @@ static int testCompareXMLToArgvFiles(const char *xml, unsigned long long flags; virDomainDefPtr vmdef = NULL; virDomainChrDef monitor_chr; + virConnectPtr conn; + + if (!(conn = virGetConnect())) + goto fail; if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0) goto fail; @@ -75,7 +80,7 @@ static int testCompareXMLToArgvFiles(const char *xml, } - if (qemudBuildCommandLine(NULL, &driver, + if (qemudBuildCommandLine(conn, &driver, vmdef, &monitor_chr, 0, flags, &argv, &qenv, NULL, NULL, migrateFrom) < 0) @@ -137,6 +142,7 @@ static int testCompareXMLToArgvFiles(const char *xml, free(qenv); } virDomainDefFree(vmdef); + virUnrefConnect(conn); return ret; } -- 1.6.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list