提交 22e82aa5 编写于 作者: E Eric Blake

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.
上级 ec128e69
......@@ -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++;
......
......@@ -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;
}
......
......@@ -67,7 +67,7 @@ struct _virObjectEventCallback {
virConnectObjectEventGenericCallback cb;
void *opaque;
virFreeCallback freecb;
int deleted;
bool deleted;
};
typedef void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册