event: use bool in more places

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.
This commit is contained in:
Eric Blake 2014-01-03 10:34:39 -07:00
parent ec128e69f1
commit 22e82aa596
3 changed files with 10 additions and 14 deletions

View File

@ -424,7 +424,7 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn,
if (cbList->callbacks[i]->cb == VIR_OBJECT_EVENT_CALLBACK(callback) && if (cbList->callbacks[i]->cb == VIR_OBJECT_EVENT_CALLBACK(callback) &&
cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE && cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE &&
cbList->callbacks[i]->conn == conn) { cbList->callbacks[i]->conn == conn) {
cbList->callbacks[i]->deleted = 1; cbList->callbacks[i]->deleted = true;
for (i = 0; i < cbList->count; i++) { for (i = 0; i < cbList->count; i++) {
if (!cbList->callbacks[i]->deleted) if (!cbList->callbacks[i]->deleted)
ret++; ret++;

View File

@ -171,7 +171,7 @@ virObjectEventCallbackListMarkDeleteID(virConnectPtr conn,
for (i = 0; i < cbList->count; i++) { for (i = 0; i < cbList->count; i++) {
if (cbList->callbacks[i]->callbackID == callbackID && if (cbList->callbacks[i]->callbackID == callbackID &&
cbList->callbacks[i]->conn == conn) { cbList->callbacks[i]->conn == conn) {
cbList->callbacks[i]->deleted = 1; cbList->callbacks[i]->deleted = true;
for (i = 0; i < cbList->count; i++) { for (i = 0; i < cbList->count; i++) {
if (!cbList->callbacks[i]->deleted) if (!cbList->callbacks[i]->deleted)
ret++; ret++;
@ -577,18 +577,18 @@ virObjectEventQueuePush(virObjectEventQueuePtr evtQueue,
} }
static int static bool
virObjectEventDispatchMatchCallback(virObjectEventPtr event, virObjectEventDispatchMatchCallback(virObjectEventPtr event,
virObjectEventCallbackPtr cb) virObjectEventCallbackPtr cb)
{ {
if (!cb) if (!cb)
return 0; return false;
if (cb->deleted) if (cb->deleted)
return 0; return false;
if (!virObjectIsClass(event, cb->klass)) if (!virObjectIsClass(event, cb->klass))
return 0; return false;
if (cb->eventID != event->eventID) if (cb->eventID != event->eventID)
return 0; return false;
if (cb->meta) { if (cb->meta) {
/* Deliberately ignoring 'id' for matching, since that /* Deliberately ignoring 'id' for matching, since that
@ -597,13 +597,9 @@ virObjectEventDispatchMatchCallback(virObjectEventPtr event,
* Xen sometimes renames guests during migration, thus * Xen sometimes renames guests during migration, thus
* leaving 'uuid' as the only truly reliable ID we can use. */ * leaving 'uuid' as the only truly reliable ID we can use. */
if (memcmp(event->meta.uuid, cb->meta->uuid, VIR_UUID_BUFLEN) == 0) return memcmp(event->meta.uuid, cb->meta->uuid, VIR_UUID_BUFLEN) == 0;
return 1;
return 0;
} else {
return 1;
} }
return true;
} }

View File

@ -67,7 +67,7 @@ struct _virObjectEventCallback {
virConnectObjectEventGenericCallback cb; virConnectObjectEventGenericCallback cb;
void *opaque; void *opaque;
virFreeCallback freecb; virFreeCallback freecb;
int deleted; bool deleted;
}; };
typedef void typedef void