When processing a virNWFilterPtr use 'nwfilter' as a variable name. When processing a virNWFilterObjPtr use 'obj' as a variable name. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/virnwfilterobj.c | 92 +++++++++++++++++++++--------------------- src/conf/virnwfilterobj.h | 7 ++-- src/nwfilter/nwfilter_driver.c | 78 +++++++++++++++++------------------ 3 files changed, 89 insertions(+), 88 deletions(-) diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index 34d843c..cb697f9 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -62,15 +62,15 @@ virNWFilterObjListFree(virNWFilterObjListPtr nwfilters) void virNWFilterObjRemove(virNWFilterObjListPtr nwfilters, - virNWFilterObjPtr nwfilter) + virNWFilterObjPtr obj) { size_t i; - virNWFilterObjUnlock(nwfilter); + virNWFilterObjUnlock(obj); for (i = 0; i < nwfilters->count; i++) { virNWFilterObjLock(nwfilters->objs[i]); - if (nwfilters->objs[i] == nwfilter) { + if (nwfilters->objs[i] == obj) { virNWFilterObjUnlock(nwfilters->objs[i]); virNWFilterObjFree(nwfilters->objs[i]); @@ -174,16 +174,16 @@ virNWFilterObjDefLoopDetect(virNWFilterObjListPtr nwfilters, int -virNWFilterObjTestUnassignDef(virNWFilterObjPtr nwfilter) +virNWFilterObjTestUnassignDef(virNWFilterObjPtr obj) { int rc = 0; - nwfilter->wantRemoved = 1; + obj->wantRemoved = 1; /* trigger the update on VMs referencing the filter */ if (virNWFilterTriggerVMFilterRebuild()) rc = -1; - nwfilter->wantRemoved = 0; + obj->wantRemoved = 0; return rc; } @@ -225,29 +225,29 @@ virNWFilterObjPtr virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters, virNWFilterDefPtr def) { - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; - nwfilter = virNWFilterObjFindByUUID(nwfilters, def->uuid); + obj = virNWFilterObjFindByUUID(nwfilters, def->uuid); - if (nwfilter) { - if (STRNEQ(def->name, nwfilter->def->name)) { + if (obj) { + if (STRNEQ(def->name, obj->def->name)) { virReportError(VIR_ERR_OPERATION_FAILED, _("filter with same UUID but different name " "('%s') already exists"), - nwfilter->def->name); - virNWFilterObjUnlock(nwfilter); + obj->def->name); + virNWFilterObjUnlock(obj); return NULL; } - virNWFilterObjUnlock(nwfilter); + virNWFilterObjUnlock(obj); } else { - nwfilter = virNWFilterObjFindByName(nwfilters, def->name); - if (nwfilter) { + obj = virNWFilterObjFindByName(nwfilters, def->name); + if (obj) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(nwfilter->def->uuid, uuidstr); + virUUIDFormat(obj->def->uuid, uuidstr); virReportError(VIR_ERR_OPERATION_FAILED, _("filter '%s' already exists with uuid %s"), def->name, uuidstr); - virNWFilterObjUnlock(nwfilter); + virNWFilterObjUnlock(obj); return NULL; } } @@ -259,49 +259,49 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters, } - if ((nwfilter = virNWFilterObjFindByName(nwfilters, def->name))) { + if ((obj = virNWFilterObjFindByName(nwfilters, def->name))) { - if (virNWFilterDefEqual(def, nwfilter->def, false)) { - virNWFilterDefFree(nwfilter->def); - nwfilter->def = def; - return nwfilter; + if (virNWFilterDefEqual(def, obj->def, false)) { + virNWFilterDefFree(obj->def); + obj->def = def; + return obj; } - nwfilter->newDef = def; + obj->newDef = def; /* trigger the update on VMs referencing the filter */ if (virNWFilterTriggerVMFilterRebuild()) { - nwfilter->newDef = NULL; - virNWFilterObjUnlock(nwfilter); + obj->newDef = NULL; + virNWFilterObjUnlock(obj); return NULL; } - virNWFilterDefFree(nwfilter->def); - nwfilter->def = def; - nwfilter->newDef = NULL; - return nwfilter; + virNWFilterDefFree(obj->def); + obj->def = def; + obj->newDef = NULL; + return obj; } - if (VIR_ALLOC(nwfilter) < 0) + if (VIR_ALLOC(obj) < 0) return NULL; - if (virMutexInitRecursive(&nwfilter->lock) < 0) { + if (virMutexInitRecursive(&obj->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize mutex")); - VIR_FREE(nwfilter); + VIR_FREE(obj); return NULL; } - virNWFilterObjLock(nwfilter); - nwfilter->active = 0; + virNWFilterObjLock(obj); + obj->active = 0; if (VIR_APPEND_ELEMENT_COPY(nwfilters->objs, - nwfilters->count, nwfilter) < 0) { - virNWFilterObjUnlock(nwfilter); - virNWFilterObjFree(nwfilter); + nwfilters->count, obj) < 0) { + virNWFilterObjUnlock(obj); + virNWFilterObjFree(obj); return NULL; } - nwfilter->def = def; + obj->def = def; - return nwfilter; + return obj; } @@ -414,7 +414,7 @@ virNWFilterObjLoadConfig(virNWFilterObjListPtr nwfilters, const char *name) { virNWFilterDefPtr def = NULL; - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; char *configFile = NULL; if (!(configFile = virFileBuildPath(configDir, name, ".xml"))) @@ -436,11 +436,11 @@ virNWFilterObjLoadConfig(virNWFilterObjListPtr nwfilters, virNWFilterSaveConfig(configDir, def) < 0) goto error; - if (!(nwfilter = virNWFilterObjAssignDef(nwfilters, def))) + if (!(obj = virNWFilterObjAssignDef(nwfilters, def))) goto error; VIR_FREE(configFile); - return nwfilter; + return obj; error: VIR_FREE(configFile); @@ -462,14 +462,14 @@ virNWFilterObjLoadAllConfigs(virNWFilterObjListPtr nwfilters, return rc; while ((ret = virDirRead(dir, &entry, configDir)) > 0) { - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; if (!virFileStripSuffix(entry->d_name, ".xml")) continue; - nwfilter = virNWFilterObjLoadConfig(nwfilters, configDir, entry->d_name); - if (nwfilter) - virNWFilterObjUnlock(nwfilter); + obj = virNWFilterObjLoadConfig(nwfilters, configDir, entry->d_name); + if (obj) + virNWFilterObjUnlock(obj); } VIR_DIR_CLOSE(dir); diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h index 49b1170..2adffd9 100644 --- a/src/conf/virnwfilterobj.h +++ b/src/conf/virnwfilterobj.h @@ -62,9 +62,10 @@ virNWFilterObjListFree(virNWFilterObjListPtr nwfilters); void virNWFilterObjRemove(virNWFilterObjListPtr nwfilters, - virNWFilterObjPtr nwfilter); + virNWFilterObjPtr obj); -void virNWFilterObjFree(virNWFilterObjPtr obj); +void +virNWFilterObjFree(virNWFilterObjPtr obj); virNWFilterObjPtr virNWFilterObjFindByUUID(virNWFilterObjListPtr nwfilters, @@ -79,7 +80,7 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters, virNWFilterDefPtr def); int -virNWFilterObjTestUnassignDef(virNWFilterObjPtr nwfilter); +virNWFilterObjTestUnassignDef(virNWFilterObjPtr obj); typedef bool (*virNWFilterObjListFilter)(virConnectPtr conn, diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index f6c419c..72b9b8e 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -357,27 +357,27 @@ static virNWFilterPtr nwfilterLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; virNWFilterPtr ret = NULL; nwfilterDriverLock(); - nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, uuid); + obj = virNWFilterObjFindByUUID(&driver->nwfilters, uuid); nwfilterDriverUnlock(); - if (!nwfilter) { + if (!obj) { virReportError(VIR_ERR_NO_NWFILTER, "%s", _("no nwfilter with matching uuid")); goto cleanup; } - if (virNWFilterLookupByUUIDEnsureACL(conn, nwfilter->def) < 0) + if (virNWFilterLookupByUUIDEnsureACL(conn, obj->def) < 0) goto cleanup; - ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid); + ret = virGetNWFilter(conn, obj->def->name, obj->def->uuid); cleanup: - if (nwfilter) - virNWFilterObjUnlock(nwfilter); + if (obj) + virNWFilterObjUnlock(obj); return ret; } @@ -386,27 +386,27 @@ static virNWFilterPtr nwfilterLookupByName(virConnectPtr conn, const char *name) { - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; virNWFilterPtr ret = NULL; nwfilterDriverLock(); - nwfilter = virNWFilterObjFindByName(&driver->nwfilters, name); + obj = virNWFilterObjFindByName(&driver->nwfilters, name); nwfilterDriverUnlock(); - if (!nwfilter) { + if (!obj) { virReportError(VIR_ERR_NO_NWFILTER, _("no nwfilter with matching name '%s'"), name); goto cleanup; } - if (virNWFilterLookupByNameEnsureACL(conn, nwfilter->def) < 0) + if (virNWFilterLookupByNameEnsureACL(conn, obj->def) < 0) goto cleanup; - ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid); + ret = virGetNWFilter(conn, obj->def->name, obj->def->uuid); cleanup: - if (nwfilter) - virNWFilterObjUnlock(nwfilter); + if (obj) + virNWFilterObjUnlock(obj); return ret; } @@ -466,7 +466,7 @@ nwfilterDefineXML(virConnectPtr conn, const char *xml) { virNWFilterDefPtr def; - virNWFilterObjPtr nwfilter = NULL; + virNWFilterObjPtr obj = NULL; virNWFilterPtr ret = NULL; if (!driver->privileged) { @@ -485,22 +485,22 @@ nwfilterDefineXML(virConnectPtr conn, if (virNWFilterDefineXMLEnsureACL(conn, def) < 0) goto cleanup; - if (!(nwfilter = virNWFilterObjAssignDef(&driver->nwfilters, def))) + if (!(obj = virNWFilterObjAssignDef(&driver->nwfilters, def))) goto cleanup; if (virNWFilterSaveDef(driver->configDir, def) < 0) { - virNWFilterObjRemove(&driver->nwfilters, nwfilter); + virNWFilterObjRemove(&driver->nwfilters, obj); def = NULL; goto cleanup; } def = NULL; - ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid); + ret = virGetNWFilter(conn, obj->def->name, obj->def->uuid); cleanup: virNWFilterDefFree(def); - if (nwfilter) - virNWFilterObjUnlock(nwfilter); + if (obj) + virNWFilterObjUnlock(obj); virNWFilterCallbackDriversUnlock(); virNWFilterUnlockFilterUpdates(); @@ -510,42 +510,42 @@ nwfilterDefineXML(virConnectPtr conn, static int -nwfilterUndefine(virNWFilterPtr obj) +nwfilterUndefine(virNWFilterPtr nwfilter) { - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; int ret = -1; nwfilterDriverLock(); virNWFilterWriteLockFilterUpdates(); virNWFilterCallbackDriversLock(); - nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid); - if (!nwfilter) { + obj = virNWFilterObjFindByUUID(&driver->nwfilters, nwfilter->uuid); + if (!obj) { virReportError(VIR_ERR_NO_NWFILTER, "%s", _("no nwfilter with matching uuid")); goto cleanup; } - if (virNWFilterUndefineEnsureACL(obj->conn, nwfilter->def) < 0) + if (virNWFilterUndefineEnsureACL(nwfilter->conn, obj->def) < 0) goto cleanup; - if (virNWFilterObjTestUnassignDef(nwfilter) < 0) { + if (virNWFilterObjTestUnassignDef(obj) < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("nwfilter is in use")); goto cleanup; } - if (virNWFilterDeleteDef(driver->configDir, nwfilter->def) < 0) + if (virNWFilterDeleteDef(driver->configDir, obj->def) < 0) goto cleanup; - virNWFilterObjRemove(&driver->nwfilters, nwfilter); - nwfilter = NULL; + virNWFilterObjRemove(&driver->nwfilters, obj); + obj = NULL; ret = 0; cleanup: - if (nwfilter) - virNWFilterObjUnlock(nwfilter); + if (obj) + virNWFilterObjUnlock(obj); virNWFilterCallbackDriversUnlock(); virNWFilterUnlockFilterUpdates(); @@ -555,32 +555,32 @@ nwfilterUndefine(virNWFilterPtr obj) static char * -nwfilterGetXMLDesc(virNWFilterPtr obj, +nwfilterGetXMLDesc(virNWFilterPtr nwfilter, unsigned int flags) { - virNWFilterObjPtr nwfilter; + virNWFilterObjPtr obj; char *ret = NULL; virCheckFlags(0, NULL); nwfilterDriverLock(); - nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid); + obj = virNWFilterObjFindByUUID(&driver->nwfilters, nwfilter->uuid); nwfilterDriverUnlock(); - if (!nwfilter) { + if (!obj) { virReportError(VIR_ERR_NO_NWFILTER, "%s", _("no nwfilter with matching uuid")); goto cleanup; } - if (virNWFilterGetXMLDescEnsureACL(obj->conn, nwfilter->def) < 0) + if (virNWFilterGetXMLDescEnsureACL(nwfilter->conn, obj->def) < 0) goto cleanup; - ret = virNWFilterDefFormat(nwfilter->def); + ret = virNWFilterDefFormat(obj->def); cleanup: - if (nwfilter) - virNWFilterObjUnlock(nwfilter); + if (obj) + virNWFilterObjUnlock(obj); return ret; } -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list