[PATCH 1/2] objecteventtest: Drop lifecycleEventCounter_reset()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The sole purpose of the lifecycleEventCounter_reset() function is
to zero out given lifecycleEventCounter struct. Well, we can let
the compiler zero it out when declaring a variable and just
remove the function.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/objecteventtest.c | 66 +++++++++--------------------------------
 1 file changed, 14 insertions(+), 52 deletions(-)

diff --git a/tests/objecteventtest.c b/tests/objecteventtest.c
index 1e84d4be11..6b1a6acd47 100644
--- a/tests/objecteventtest.c
+++ b/tests/objecteventtest.c
@@ -82,17 +82,6 @@ typedef struct {
     int deletedEvents;
 } lifecycleEventCounter;
 
-static void
-lifecycleEventCounter_reset(lifecycleEventCounter *counter)
-{
-    counter->startEvents = 0;
-    counter->stopEvents = 0;
-    counter->defineEvents = 0;
-    counter->undefineEvents = 0;
-    counter->unexpectedEvents = 0;
-    counter->createdEvents = 0;
-    counter->deletedEvents = 0;
-}
 
 typedef struct {
     virConnectPtr conn;
@@ -202,13 +191,11 @@ static int
 testDomainCreateXMLOld(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virDomainPtr dom = NULL;
     int ret = -1;
     bool registered = false;
 
-    lifecycleEventCounter_reset(&counter);
-
     if (virConnectDomainEventRegister(test->conn,
                                       domainLifecycleCb,
                                       &counter, NULL) != 0)
@@ -242,14 +229,12 @@ static int
 testDomainCreateXMLNew(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int eventId = VIR_DOMAIN_EVENT_ID_LIFECYCLE;
     virDomainPtr dom = NULL;
     int id;
     int ret = -1;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectDomainEventRegisterAny(test->conn, NULL, eventId,
                            VIR_DOMAIN_EVENT_CALLBACK(&domainLifecycleCb),
                            &counter, NULL);
@@ -283,15 +268,13 @@ static int
 testDomainCreateXMLMixed(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virDomainPtr dom;
     int ret = -1;
     int id1 = -1;
     int id2 = -1;
     bool registered = false;
 
-    lifecycleEventCounter_reset(&counter);
-
     /* Fun with mixing old and new API, also with global and
      * per-domain.  Handler should be fired three times, once for each
      * registration.  */
@@ -360,14 +343,12 @@ static int
 testDomainDefine(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int eventId = VIR_DOMAIN_EVENT_ID_LIFECYCLE;
     virDomainPtr dom = NULL;
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectDomainEventRegisterAny(test->conn, NULL, eventId,
                            VIR_DOMAIN_EVENT_CALLBACK(&domainLifecycleCb),
                            &counter, NULL);
@@ -411,7 +392,7 @@ static int
 testDomainStartStopEvent(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int eventId = VIR_DOMAIN_EVENT_ID_LIFECYCLE;
     int id;
     int ret = -1;
@@ -419,8 +400,6 @@ testDomainStartStopEvent(const void *data)
     virConnectPtr conn2 = NULL;
     virDomainPtr dom2 = NULL;
 
-    lifecycleEventCounter_reset(&counter);
-
     dom = virDomainLookupByName(test->conn, "test");
     if (dom == NULL)
         return -1;
@@ -476,13 +455,11 @@ static int
 testNetworkCreateXML(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virNetworkPtr net;
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectNetworkEventRegisterAny(test->conn, NULL,
                            VIR_NETWORK_EVENT_ID_LIFECYCLE,
                            VIR_NETWORK_EVENT_CALLBACK(&networkLifecycleCb),
@@ -512,13 +489,11 @@ static int
 testNetworkDefine(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virNetworkPtr net;
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectNetworkEventRegisterAny(test->conn, NULL,
                            VIR_NETWORK_EVENT_ID_LIFECYCLE,
                            VIR_NETWORK_EVENT_CALLBACK(&networkLifecycleCb),
@@ -563,15 +538,13 @@ static int
 testNetworkStartStopEvent(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int id;
     int ret = 0;
 
     if (!test->net)
         return -1;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectNetworkEventRegisterAny(test->conn, test->net,
                            VIR_NETWORK_EVENT_ID_LIFECYCLE,
                            VIR_NETWORK_EVENT_CALLBACK(&networkLifecycleCb),
@@ -599,13 +572,11 @@ static int
 testStoragePoolCreateXML(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virStoragePoolPtr pool;
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectStoragePoolEventRegisterAny(test->conn, NULL,
                       VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
                       VIR_STORAGE_POOL_EVENT_CALLBACK(&storagePoolLifecycleCb),
@@ -635,13 +606,11 @@ static int
 testStoragePoolDefine(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virStoragePoolPtr pool;
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectStoragePoolEventRegisterAny(test->conn, NULL,
                       VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
                       VIR_STORAGE_POOL_EVENT_CALLBACK(&storagePoolLifecycleCb),
@@ -686,7 +655,7 @@ static int
 testStoragePoolStartStopEvent(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int refreshCounter;
     int id1, id2;
     int ret = 0;
@@ -694,7 +663,6 @@ testStoragePoolStartStopEvent(const void *data)
     if (!test->pool)
         return -1;
 
-    lifecycleEventCounter_reset(&counter);
     refreshCounter = 0;
 
     id1 = virConnectStoragePoolEventRegisterAny(test->conn, test->pool,
@@ -730,12 +698,10 @@ static int
 testStoragePoolBuild(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectStoragePoolEventRegisterAny(test->conn, NULL,
                       VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
                       VIR_STORAGE_POOL_EVENT_CALLBACK(&storagePoolLifecycleCb),
@@ -762,12 +728,10 @@ static int
 testStoragePoolDelete(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectStoragePoolEventRegisterAny(test->conn, NULL,
                       VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
                       VIR_STORAGE_POOL_EVENT_CALLBACK(&storagePoolLifecycleCb),
@@ -793,13 +757,11 @@ static int
 testNodeDeviceCreateXML(const void *data)
 {
     const objecteventTest *test = data;
-    lifecycleEventCounter counter;
+    lifecycleEventCounter counter = { 0 };
     virNodeDevicePtr dev;
     int id;
     int ret = 0;
 
-    lifecycleEventCounter_reset(&counter);
-
     id = virConnectNodeDeviceEventRegisterAny(test->conn, NULL,
                         VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE,
                         VIR_NODE_DEVICE_EVENT_CALLBACK(&nodeDeviceLifecycleCb),
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux