virEventRunDefaultImpl() function returns an
invariant result, so turn it to void. Remove all
redundant check which depends on it returning value
Fixes: 946a25274c ("util: switch to use the GLib event loop impl")
Signed-off-by: Artem Chernyshev <artem.chernyshev(a)red-soft.ru>
---
examples/c/misc/event-test.c | 5 +--
include/libvirt/libvirt-event.h | 2 +-
src/rpc/virnetdaemon.c | 6 +--
src/util/virevent.c | 7 +--
src/util/vireventglib.c | 4 +-
src/util/vireventglib.h | 2 +-
tests/objecteventtest.c | 76 ++++++++++++++++-----------------
tests/qemucapsprobe.c | 5 +--
tests/qemumonitortestutils.c | 8 +---
tests/virnetsockettest.c | 3 +-
tools/vsh.c | 3 +-
11 files changed, 47 insertions(+), 74 deletions(-)
diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c
index 88d99dff56..9c54ad5176 100644
--- a/examples/c/misc/event-test.c
+++ b/examples/c/misc/event-test.c
@@ -1367,10 +1367,7 @@ main(int argc, char **argv)
}
while (run) {
- if (virEventRunDefaultImpl() < 0) {
- fprintf(stderr, "Failed to run event loop: %s\n",
- virGetLastErrorMessage());
- }
+ virEventRunDefaultImpl();
}
printf("Deregistering event callbacks\n");
diff --git a/include/libvirt/libvirt-event.h b/include/libvirt/libvirt-event.h
index 41e662a237..c8af377670 100644
--- a/include/libvirt/libvirt-event.h
+++ b/include/libvirt/libvirt-event.h
@@ -191,7 +191,7 @@ void virEventRegisterImpl(virEventAddHandleFunc addHandle,
virEventRemoveTimeoutFunc removeTimeout);
int virEventRegisterDefaultImpl(void);
-int virEventRunDefaultImpl(void);
+void virEventRunDefaultImpl(void);
int virEventAddHandle(int fd, int events,
virEventHandleCallback cb,
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 9795418126..269198d4b6 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -834,11 +834,7 @@ virNetDaemonRun(virNetDaemon *dmn)
virNetDaemonShutdownTimerUpdate(dmn);
virObjectUnlock(dmn);
- if (virEventRunDefaultImpl() < 0) {
- virObjectLock(dmn);
- VIR_DEBUG("Loop iteration error, exiting");
- break;
- }
+ virEventRunDefaultImpl();
virObjectLock(dmn);
virHashForEach(dmn->servers, daemonServerProcessClients, NULL);
diff --git a/src/util/virevent.c b/src/util/virevent.c
index e625183a7f..65ae5256a2 100644
--- a/src/util/virevent.c
+++ b/src/util/virevent.c
@@ -350,14 +350,11 @@ int virEventRegisterDefaultImpl(void)
* ...print error...
* }
*
- * Returns 0 on success, -1 on failure.
- *
* Since: 0.9.0
*/
-int virEventRunDefaultImpl(void)
+void virEventRunDefaultImpl(void)
{
VIR_DEBUG("running default event implementation");
virResetLastError();
-
- return virEventGLibRunOnce();
+ virEventGLibRunOnce();
}
diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c
index 023dc37445..b8f99f3167 100644
--- a/src/util/vireventglib.c
+++ b/src/util/vireventglib.c
@@ -510,9 +510,7 @@ void virEventGLibRegister(void)
}
-int virEventGLibRunOnce(void)
+void virEventGLibRunOnce(void)
{
g_main_context_iteration(NULL, TRUE);
-
- return 0;
}
diff --git a/src/util/vireventglib.h b/src/util/vireventglib.h
index ef68abaa20..59ee20841f 100644
--- a/src/util/vireventglib.h
+++ b/src/util/vireventglib.h
@@ -25,4 +25,4 @@
void virEventGLibRegister(void);
-int virEventGLibRunOnce(void);
+void virEventGLibRunOnce(void);
diff --git a/tests/objecteventtest.c b/tests/objecteventtest.c
index 7110f54139..6568787435 100644
--- a/tests/objecteventtest.c
+++ b/tests/objecteventtest.c
@@ -200,9 +200,11 @@ testDomainCreateXMLOld(const void *data)
registered = true;
dom = virDomainCreateXML(test->conn, domainDef, 0);
- if (dom == NULL || virEventRunDefaultImpl() < 0)
+ if (dom == NULL)
goto cleanup;
+ virEventRunDefaultImpl();
+
if (counter.startEvents != 1 || counter.unexpectedEvents > 0)
goto cleanup;
@@ -239,9 +241,11 @@ testDomainCreateXMLNew(const void *data)
goto cleanup;
dom = virDomainCreateXML(test->conn, domainDef, 0);
- if (dom == NULL || virEventRunDefaultImpl() < 0)
+ if (dom == NULL)
goto cleanup;
+ virEventRunDefaultImpl();
+
if (counter.startEvents != 1 || counter.unexpectedEvents > 0)
goto cleanup;
@@ -302,9 +306,11 @@ testDomainCreateXMLMixed(const void *data)
virDomainFree(dom);
dom = virDomainCreateXML(test->conn, domainDef, 0);
- if (dom == NULL || virEventRunDefaultImpl() < 0)
+ if (dom == NULL)
goto cleanup;
+ virEventRunDefaultImpl();
+
if (counter.startEvents != 3 || counter.unexpectedEvents > 0)
goto cleanup;
@@ -353,9 +359,10 @@ testDomainDefine(const void *data)
/* Make sure the define event is triggered */
dom = virDomainDefineXML(test->conn, domainDef);
- if (dom == NULL || virEventRunDefaultImpl() < 0) {
+ if (dom == NULL)
goto cleanup;
- }
+
+ virEventRunDefaultImpl();
if (counter.defineEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -364,9 +371,7 @@ testDomainDefine(const void *data)
/* Make sure the undefine event is triggered */
virDomainUndefine(dom);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.undefineEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -406,8 +411,7 @@ testDomainStartStopEvent(const void *data)
if (virDomainCreate(dom) < 0)
goto cleanup;
- if (virEventRunDefaultImpl() < 0)
- goto cleanup;
+ virEventRunDefaultImpl();
if (counter.startEvents != 1 || counter.stopEvents != 1 ||
counter.unexpectedEvents > 0)
@@ -425,8 +429,7 @@ testDomainStartStopEvent(const void *data)
if (virDomainCreate(dom2) < 0)
goto cleanup;
- if (virEventRunDefaultImpl() < 0)
- goto cleanup;
+ virEventRunDefaultImpl();
if (counter.startEvents != 2 || counter.stopEvents != 2 ||
counter.unexpectedEvents > 0)
@@ -459,9 +462,10 @@ testNetworkCreateXML(const void *data)
&counter, NULL);
net = virNetworkCreateXML(test->conn, networkDef);
- if (!net || virEventRunDefaultImpl() < 0) {
+ if (!net)
goto cleanup;
- }
+
+ virEventRunDefaultImpl();
if (counter.startEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -494,9 +498,10 @@ testNetworkDefine(const void *data)
/* Make sure the define event is triggered */
net = virNetworkDefineXML(test->conn, networkDef);
- if (!net || virEventRunDefaultImpl() < 0) {
+ if (!net)
goto cleanup;
- }
+
+ virEventRunDefaultImpl();
if (counter.defineEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -505,9 +510,7 @@ testNetworkDefine(const void *data)
/* Make sure the undefine event is triggered */
virNetworkUndefine(net);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.undefineEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -541,9 +544,7 @@ testNetworkStartStopEvent(const void *data)
virNetworkCreate(test->net);
virNetworkDestroy(test->net);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.startEvents != 1 || counter.stopEvents != 1 ||
counter.unexpectedEvents > 0) {
@@ -572,9 +573,10 @@ testStoragePoolCreateXML(const void *data)
&counter, NULL);
pool = virStoragePoolCreateXML(test->conn, storagePoolDef, 0);
- if (!pool || virEventRunDefaultImpl() < 0) {
+ if (!pool)
goto cleanup;
- }
+
+ virEventRunDefaultImpl();
if (counter.startEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -607,9 +609,10 @@ testStoragePoolDefine(const void *data)
/* Make sure the define event is triggered */
pool = virStoragePoolDefineXML(test->conn, storagePoolDef, 0);
- if (!pool || virEventRunDefaultImpl() < 0) {
+ if (!pool)
goto cleanup;
- }
+
+ virEventRunDefaultImpl();
if (counter.defineEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -618,9 +621,7 @@ testStoragePoolDefine(const void *data)
/* Make sure the undefine event is triggered */
virStoragePoolUndefine(pool);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.undefineEvents != 1 || counter.unexpectedEvents > 0) {
goto cleanup;
@@ -659,9 +660,7 @@ testStoragePoolStartStopEvent(const void *data)
virStoragePoolRefresh(test->pool, 0);
virStoragePoolDestroy(test->pool);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.startEvents != 1 || counter.stopEvents != 1 ||
refreshCounter != 1 || counter.unexpectedEvents > 0) {
@@ -690,9 +689,7 @@ testStoragePoolBuild(const void *data)
virStoragePoolBuild(test->pool, 0);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.createdEvents != 1) {
goto cleanup;
@@ -719,9 +716,7 @@ testStoragePoolDelete(const void *data)
virStoragePoolDelete(test->pool, 0);
- if (virEventRunDefaultImpl() < 0) {
- goto cleanup;
- }
+ virEventRunDefaultImpl();
if (counter.deletedEvents != 1) {
goto cleanup;
@@ -748,9 +743,10 @@ testNodeDeviceCreateXML(const void *data)
dev = virNodeDeviceCreateXML(test->conn, nodeDeviceDef, 0);
virNodeDeviceDestroy(dev);
- if (!dev || virEventRunDefaultImpl() < 0) {
+ if (!dev)
goto cleanup;
- }
+
+ virEventRunDefaultImpl();
if (counter.createdEvents != 1 || counter.deletedEvents != 1 ||
counter.unexpectedEvents > 0) {
diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
index 76c18f0dcd..47f5b71642 100644
--- a/tests/qemucapsprobe.c
+++ b/tests/qemucapsprobe.c
@@ -33,10 +33,7 @@ static void
eventLoop(void *opaque G_GNUC_UNUSED)
{
while (1) {
- if (virEventRunDefaultImpl() < 0) {
- fprintf(stderr, "Failed to run event loop: %s\n",
- virGetLastErrorMessage());
- }
+ virEventRunDefaultImpl();
}
}
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 16a4096c98..d1a6424167 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -349,13 +349,7 @@ qemuMonitorTestWorker(void *opaque)
}
}
- if (virEventRunDefaultImpl() < 0) {
- VIR_WITH_MUTEX_LOCK_GUARD(&test->lock) {
- test->quit = true;
- test->running = false;
- return;
- }
- }
+ virEventRunDefaultImpl();
}
}
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 0e9cd8a81c..9949189eb9 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -229,8 +229,7 @@ testSocketAccept(const void *opaque)
goto cleanup;
while (rsock == NULL) {
- if (virEventRunDefaultImpl() < 0)
- break;
+ virEventRunDefaultImpl();
}
for (i = 0; i < nlsock; i++) {
diff --git a/tools/vsh.c b/tools/vsh.c
index 65deaa77e8..75a189bcb7 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2040,8 +2040,7 @@ vshEventLoop(void *opaque)
if (quit)
break;
- if (virEventRunDefaultImpl() < 0)
- vshReportError(ctl);
+ virEventRunDefaultImpl();
}
}
--
2.43.0