[PATCH 1/2] event: use bool in more places

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

 



No need to use an int that only ever stores 0 and 1.

* src/conf/object_event_private.h (_virObjectEventCallback):
Change deleted to bool.
* src/conf/object_event.c (virObjectEventDispatchMatchCallback):
Switch return type to bool.
(virObjectEventCallbackListMarkDeleteID): Update client.
* src/conf/domain_event.c (virDomainEventCallbackListMarkDelete):
Likewise.
---
 src/conf/domain_event.c         |  2 +-
 src/conf/object_event.c         | 20 ++++++++------------
 src/conf/object_event_private.h |  2 +-
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 5e5bac5..df370f6 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -424,7 +424,7 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn,
         if (cbList->callbacks[i]->cb == VIR_OBJECT_EVENT_CALLBACK(callback) &&
             cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE &&
             cbList->callbacks[i]->conn == conn) {
-            cbList->callbacks[i]->deleted = 1;
+            cbList->callbacks[i]->deleted = true;
             for (i = 0; i < cbList->count; i++) {
                 if (!cbList->callbacks[i]->deleted)
                     ret++;
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index dad98d6..5173fdf 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -171,7 +171,7 @@ virObjectEventCallbackListMarkDeleteID(virConnectPtr conn,
     for (i = 0; i < cbList->count; i++) {
         if (cbList->callbacks[i]->callbackID == callbackID &&
             cbList->callbacks[i]->conn == conn) {
-            cbList->callbacks[i]->deleted = 1;
+            cbList->callbacks[i]->deleted = true;
             for (i = 0; i < cbList->count; i++) {
                 if (!cbList->callbacks[i]->deleted)
                     ret++;
@@ -577,18 +577,18 @@ virObjectEventQueuePush(virObjectEventQueuePtr evtQueue,
 }


-static int
+static bool
 virObjectEventDispatchMatchCallback(virObjectEventPtr event,
                                     virObjectEventCallbackPtr cb)
 {
     if (!cb)
-        return 0;
+        return false;
     if (cb->deleted)
-        return 0;
+        return false;
     if (!virObjectIsClass(event, cb->klass))
-        return 0;
+        return false;
     if (cb->eventID != event->eventID)
-        return 0;
+        return false;

     if (cb->meta) {
         /* Deliberately ignoring 'id' for matching, since that
@@ -597,13 +597,9 @@ virObjectEventDispatchMatchCallback(virObjectEventPtr event,
          * Xen sometimes renames guests during migration, thus
          * leaving 'uuid' as the only truly reliable ID we can use. */

-        if (memcmp(event->meta.uuid, cb->meta->uuid, VIR_UUID_BUFLEN) == 0)
-            return 1;
-
-        return 0;
-    } else {
-        return 1;
+        return memcmp(event->meta.uuid, cb->meta->uuid, VIR_UUID_BUFLEN) == 0;
     }
+    return true;
 }


diff --git a/src/conf/object_event_private.h b/src/conf/object_event_private.h
index bc80425..d2e4666 100644
--- a/src/conf/object_event_private.h
+++ b/src/conf/object_event_private.h
@@ -67,7 +67,7 @@ struct _virObjectEventCallback {
     virConnectObjectEventGenericCallback cb;
     void *opaque;
     virFreeCallback freecb;
-    int deleted;
+    bool deleted;
 };

 typedef void
-- 
1.8.4.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]