[PATCH 10/13] nodedev: Use consistent names for driver variables

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

 



A virNodeDeviceObjPtr is an @obj

A virNodeDeviceObjListPtr is a @devs

A virNodeDevicePtr is a @device

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/node_device/node_device_driver.c | 70 ++++++++++++++++++------------------
 src/node_device/node_device_hal.c    | 42 +++++++++++-----------
 src/node_device/node_device_udev.c   | 50 +++++++++++++-------------
 3 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 279c133..fe2cb3c 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -253,7 +253,7 @@ nodeDeviceLookupByName(virConnectPtr conn,
                        const char *name)
 {
     virNodeDeviceObjPtr obj;
-    virNodeDevicePtr ret = NULL;
+    virNodeDevicePtr device = NULL;
 
     if (!(obj = nodeDeviceObjFindByName(name)))
         return NULL;
@@ -261,14 +261,14 @@ nodeDeviceLookupByName(virConnectPtr conn,
     if (virNodeDeviceLookupByNameEnsureACL(conn, obj->def) < 0)
         goto cleanup;
 
-    if ((ret = virGetNodeDevice(conn, name))) {
-        if (VIR_STRDUP(ret->parent, obj->def->parent) < 0)
-            virObjectUnref(ret);
+    if ((device = virGetNodeDevice(conn, name))) {
+        if (VIR_STRDUP(device->parent, obj->def->parent) < 0)
+            virObjectUnref(device);
     }
 
  cleanup:
     virNodeDeviceObjUnlock(obj);
-    return ret;
+    return device;
 }
 
 
@@ -282,7 +282,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
     virNodeDeviceObjListPtr devs = &driver->devs;
     virNodeDevCapsDefPtr cap = NULL;
     virNodeDeviceObjPtr obj = NULL;
-    virNodeDevicePtr dev = NULL;
+    virNodeDevicePtr device = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -304,9 +304,9 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
                         if (virNodeDeviceLookupSCSIHostByWWNEnsureACL(conn, obj->def) < 0)
                             goto out;
 
-                        if ((dev = virGetNodeDevice(conn, obj->def->name))) {
-                            if (VIR_STRDUP(dev->parent, obj->def->parent) < 0)
-                                virObjectUnref(dev);
+                        if ((device = virGetNodeDevice(conn, obj->def->name))) {
+                            if (VIR_STRDUP(device->parent, obj->def->parent) < 0)
+                                virObjectUnref(device);
                         }
                         virNodeDeviceObjUnlock(obj);
                         goto out;
@@ -321,12 +321,12 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
 
  out:
     nodeDeviceUnlock();
-    return dev;
+    return device;
 }
 
 
 char *
-nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
+nodeDeviceGetXMLDesc(virNodeDevicePtr device,
                      unsigned int flags)
 {
     virNodeDeviceObjPtr obj;
@@ -334,10 +334,10 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
 
     virCheckFlags(0, NULL);
 
-    if (!(obj = nodeDeviceObjFindByName(dev->name)))
+    if (!(obj = nodeDeviceObjFindByName(device->name)))
         return NULL;
 
-    if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
+    if (virNodeDeviceGetXMLDescEnsureACL(device->conn, obj->def) < 0)
         goto cleanup;
 
     if (nodeDeviceUpdateDriverName(obj->def) < 0)
@@ -355,15 +355,15 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
 
 
 char *
-nodeDeviceGetParent(virNodeDevicePtr dev)
+nodeDeviceGetParent(virNodeDevicePtr device)
 {
     virNodeDeviceObjPtr obj;
     char *ret = NULL;
 
-    if (!(obj = nodeDeviceObjFindByName(dev->name)))
+    if (!(obj = nodeDeviceObjFindByName(device->name)))
         return NULL;
 
-    if (virNodeDeviceGetParentEnsureACL(dev->conn, obj->def) < 0)
+    if (virNodeDeviceGetParentEnsureACL(device->conn, obj->def) < 0)
         goto cleanup;
 
     if (obj->def->parent) {
@@ -381,17 +381,17 @@ nodeDeviceGetParent(virNodeDevicePtr dev)
 
 
 int
-nodeDeviceNumOfCaps(virNodeDevicePtr dev)
+nodeDeviceNumOfCaps(virNodeDevicePtr device)
 {
     virNodeDeviceObjPtr obj;
     virNodeDevCapsDefPtr caps;
     int ncaps = 0;
     int ret = -1;
 
-    if (!(obj = nodeDeviceObjFindByName(dev->name)))
+    if (!(obj = nodeDeviceObjFindByName(device->name)))
         return -1;
 
-    if (virNodeDeviceNumOfCapsEnsureACL(dev->conn, obj->def) < 0)
+    if (virNodeDeviceNumOfCapsEnsureACL(device->conn, obj->def) < 0)
         goto cleanup;
 
     for (caps = obj->def->caps; caps; caps = caps->next) {
@@ -418,7 +418,7 @@ nodeDeviceNumOfCaps(virNodeDevicePtr dev)
 
 
 int
-nodeDeviceListCaps(virNodeDevicePtr dev,
+nodeDeviceListCaps(virNodeDevicePtr device,
                    char **const names,
                    int maxnames)
 {
@@ -427,10 +427,10 @@ nodeDeviceListCaps(virNodeDevicePtr dev,
     int ncaps = 0;
     int ret = -1;
 
-    if (!(obj = nodeDeviceObjFindByName(dev->name)))
+    if (!(obj = nodeDeviceObjFindByName(device->name)))
         return -1;
 
-    if (virNodeDeviceListCapsEnsureACL(dev->conn, obj->def) < 0)
+    if (virNodeDeviceListCapsEnsureACL(device->conn, obj->def) < 0)
         goto cleanup;
 
     for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) {
@@ -502,7 +502,7 @@ nodeDeviceGetTime(time_t *t)
 static virNodeDevicePtr
 find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
 {
-    virNodeDevicePtr dev = NULL;
+    virNodeDevicePtr device = NULL;
     time_t start = 0, now = 0;
 
     /* The thread that creates the device takes the driver lock, so we
@@ -518,9 +518,9 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
 
         virWaitForDevices();
 
-        dev = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0);
+        device = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0);
 
-        if (dev != NULL)
+        if (device != NULL)
             break;
 
         sleep(5);
@@ -530,7 +530,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
 
     nodeDeviceLock();
 
-    return dev;
+    return device;
 }
 
 
@@ -542,7 +542,7 @@ nodeDeviceCreateXML(virConnectPtr conn,
     virNodeDeviceDefPtr def = NULL;
     char *wwnn = NULL, *wwpn = NULL;
     int parent_host = -1;
-    virNodeDevicePtr dev = NULL;
+    virNodeDevicePtr device = NULL;
     const char *virt_type = NULL;
 
     virCheckFlags(0, NULL);
@@ -566,11 +566,11 @@ nodeDeviceCreateXML(virConnectPtr conn,
     if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0)
         goto cleanup;
 
-    dev = find_new_device(conn, wwnn, wwpn);
+    device = find_new_device(conn, wwnn, wwpn);
     /* We don't check the return value, because one way or another,
      * we're returning what we get... */
 
-    if (dev == NULL)
+    if (device == NULL)
         virReportError(VIR_ERR_NO_NODE_DEVICE,
                        _("no node device for '%s' with matching "
                          "wwnn '%s' and wwpn '%s'"),
@@ -580,12 +580,12 @@ nodeDeviceCreateXML(virConnectPtr conn,
     virNodeDeviceDefFree(def);
     VIR_FREE(wwnn);
     VIR_FREE(wwpn);
-    return dev;
+    return device;
 }
 
 
 int
-nodeDeviceDestroy(virNodeDevicePtr dev)
+nodeDeviceDestroy(virNodeDevicePtr device)
 {
     int ret = -1;
     virNodeDeviceObjPtr obj = NULL;
@@ -593,12 +593,12 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
     char *wwnn = NULL, *wwpn = NULL;
     int parent_host = -1;
 
-    if (!(obj = nodeDeviceObjFindByName(dev->name)))
+    if (!(obj = nodeDeviceObjFindByName(device->name)))
         return -1;
 
     nodeDeviceLock();
 
-    if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0)
+    if (virNodeDeviceDestroyEnsureACL(device->conn, obj->def) < 0)
         goto cleanup;
 
     if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) < 0)
@@ -631,7 +631,7 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
 
 int
 nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
-                                      virNodeDevicePtr dev,
+                                      virNodeDevicePtr device,
                                       int eventID,
                                       virConnectNodeDeviceEventGenericCallback callback,
                                       void *opaque,
@@ -643,7 +643,7 @@ nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
         goto cleanup;
 
     if (virNodeDeviceEventStateRegisterID(conn, driver->nodeDeviceEventState,
-                                          dev, eventID, callback,
+                                          device, eventID, callback,
                                           opaque, freecb, &callbackID) < 0)
         callbackID = -1;
  cleanup:
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index e76201b..11b9aab 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -457,7 +457,7 @@ dev_create(const char *udi)
 {
     LibHalContext *ctx;
     char *parent_key = NULL;
-    virNodeDeviceObjPtr dev = NULL;
+    virNodeDeviceObjPtr obj = NULL;
     virNodeDeviceDefPtr def = NULL;
     const char *name = hal_name(udi);
     int rv;
@@ -493,17 +493,17 @@ dev_create(const char *udi)
     /* Some devices don't have a path in sysfs, so ignore failure */
     (void)get_str_prop(ctx, udi, "linux.sysfs_path", &devicePath);
 
-    dev = virNodeDeviceObjAssignDef(&driver->devs, def);
-    if (!dev) {
+    obj = virNodeDeviceObjAssignDef(&driver->devs, def);
+    if (!obj) {
         VIR_FREE(devicePath);
         goto failure;
     }
 
-    dev->privateData = privData;
-    dev->privateFree = free_udi;
-    dev->def->sysfs_path = devicePath;
+    obj->privateData = privData;
+    obj->privateFree = free_udi;
+    obj->def->sysfs_path = devicePath;
 
-    virNodeDeviceObjUnlock(dev);
+    virNodeDeviceObjUnlock(obj);
 
     nodeDeviceUnlock();
     return;
@@ -520,21 +520,21 @@ static void
 dev_refresh(const char *udi)
 {
     const char *name = hal_name(udi);
-    virNodeDeviceObjPtr dev;
+    virNodeDeviceObjPtr obj;
 
     nodeDeviceLock();
-    dev = virNodeDeviceObjFindByName(&driver->devs, name);
-    if (dev) {
+    obj = virNodeDeviceObjFindByName(&driver->devs, name);
+    if (obj) {
         /* Simply "rediscover" device -- incrementally handling changes
          * to sub-capabilities (like net.80203) is nasty ... so avoid it.
          */
-        virNodeDeviceObjRemove(&driver->devs, &dev);
+        virNodeDeviceObjRemove(&driver->devs, &obj);
     } else {
         VIR_DEBUG("no device named %s", name);
     }
     nodeDeviceUnlock();
 
-    if (dev)
+    if (obj)
         dev_create(udi);
 }
 
@@ -552,13 +552,13 @@ device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED,
                const char *udi)
 {
     const char *name = hal_name(udi);
-    virNodeDeviceObjPtr dev;
+    virNodeDeviceObjPtr obj;
 
     nodeDeviceLock();
-    dev = virNodeDeviceObjFindByName(&driver->devs, name);
+    obj = virNodeDeviceObjFindByName(&driver->devs, name);
     VIR_DEBUG("%s", name);
-    if (dev)
-        virNodeDeviceObjRemove(&driver->devs, &dev);
+    if (obj)
+        virNodeDeviceObjRemove(&driver->devs, &obj);
     else
         VIR_DEBUG("no device named %s", name);
     nodeDeviceUnlock();
@@ -570,15 +570,15 @@ device_cap_added(LibHalContext *ctx,
                  const char *udi, const char *cap)
 {
     const char *name = hal_name(udi);
-    virNodeDeviceObjPtr dev;
+    virNodeDeviceObjPtr obj;
 
     nodeDeviceLock();
-    dev = virNodeDeviceObjFindByName(&driver->devs, name);
+    obj = virNodeDeviceObjFindByName(&driver->devs, name);
     nodeDeviceUnlock();
     VIR_DEBUG("%s %s", cap, name);
-    if (dev) {
-        (void)gather_capability(ctx, udi, cap, &dev->def->caps);
-        virNodeDeviceObjUnlock(dev);
+    if (obj) {
+        (void)gather_capability(ctx, udi, cap, &obj->def->caps);
+        virNodeDeviceObjUnlock(obj);
     } else {
         VIR_DEBUG("no device named %s", name);
     }
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9ff8691..6fd8896 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1276,27 +1276,27 @@ udevGetDeviceDetails(struct udev_device *device,
 static int
 udevRemoveOneDevice(struct udev_device *device)
 {
-    virNodeDeviceObjPtr dev = NULL;
+    virNodeDeviceObjPtr obj = NULL;
     virObjectEventPtr event = NULL;
     const char *name = NULL;
     int ret = -1;
 
     name = udev_device_get_syspath(device);
-    dev = virNodeDeviceObjFindBySysfsPath(&driver->devs, name);
+    obj = virNodeDeviceObjFindBySysfsPath(&driver->devs, name);
 
-    if (!dev) {
+    if (!obj) {
         VIR_DEBUG("Failed to find device to remove that has udev name '%s'",
                   name);
         goto cleanup;
     }
 
-    event = virNodeDeviceEventLifecycleNew(dev->def->name,
+    event = virNodeDeviceEventLifecycleNew(obj->def->name,
                                            VIR_NODE_DEVICE_EVENT_DELETED,
                                            0);
 
     VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
-              dev->def->name, name);
-    virNodeDeviceObjRemove(&driver->devs, &dev);
+              obj->def->name, name);
+    virNodeDeviceObjRemove(&driver->devs, &obj);
 
     ret = 0;
  cleanup:
@@ -1312,7 +1312,7 @@ udevSetParent(struct udev_device *device,
 {
     struct udev_device *parent_device = NULL;
     const char *parent_sysfs_path = NULL;
-    virNodeDeviceObjPtr dev = NULL;
+    virNodeDeviceObjPtr obj = NULL;
     int ret = -1;
 
     parent_device = device;
@@ -1330,14 +1330,14 @@ udevSetParent(struct udev_device *device,
             goto cleanup;
         }
 
-        dev = virNodeDeviceObjFindBySysfsPath(&driver->devs,
+        obj = virNodeDeviceObjFindBySysfsPath(&driver->devs,
                                               parent_sysfs_path);
-        if (dev != NULL) {
-            if (VIR_STRDUP(def->parent, dev->def->name) < 0) {
-                virNodeDeviceObjUnlock(dev);
+        if (obj != NULL) {
+            if (VIR_STRDUP(def->parent, obj->def->name) < 0) {
+                virNodeDeviceObjUnlock(obj);
                 goto cleanup;
             }
-            virNodeDeviceObjUnlock(dev);
+            virNodeDeviceObjUnlock(obj);
 
             if (VIR_STRDUP(def->parent_sysfs_path, parent_sysfs_path) < 0)
                 goto cleanup;
@@ -1359,7 +1359,7 @@ static int
 udevAddOneDevice(struct udev_device *device)
 {
     virNodeDeviceDefPtr def = NULL;
-    virNodeDeviceObjPtr dev = NULL;
+    virNodeDeviceObjPtr obj = NULL;
     virObjectEventPtr event = NULL;
     bool new_device = true;
     int ret = -1;
@@ -1388,26 +1388,26 @@ udevAddOneDevice(struct udev_device *device)
     if (udevSetParent(device, def) != 0)
         goto cleanup;
 
-    dev = virNodeDeviceObjFindByName(&driver->devs, def->name);
-    if (dev) {
-        virNodeDeviceObjUnlock(dev);
+    obj = virNodeDeviceObjFindByName(&driver->devs, def->name);
+    if (obj) {
+        virNodeDeviceObjUnlock(obj);
         new_device = false;
     }
 
     /* If this is a device change, the old definition will be freed
      * and the current definition will take its place. */
-    dev = virNodeDeviceObjAssignDef(&driver->devs, def);
-    if (dev == NULL)
+    obj = virNodeDeviceObjAssignDef(&driver->devs, def);
+    if (obj == NULL)
         goto cleanup;
 
     if (new_device)
-        event = virNodeDeviceEventLifecycleNew(dev->def->name,
+        event = virNodeDeviceEventLifecycleNew(obj->def->name,
                                                VIR_NODE_DEVICE_EVENT_CREATED,
                                                0);
     else
-        event = virNodeDeviceEventUpdateNew(dev->def->name);
+        event = virNodeDeviceEventUpdateNew(obj->def->name);
 
-    virNodeDeviceObjUnlock(dev);
+    virNodeDeviceObjUnlock(obj);
 
     ret = 0;
 
@@ -1670,7 +1670,7 @@ static int
 udevSetupSystemDev(void)
 {
     virNodeDeviceDefPtr def = NULL;
-    virNodeDeviceObjPtr dev = NULL;
+    virNodeDeviceObjPtr obj = NULL;
     int ret = -1;
 
     if (VIR_ALLOC(def) < 0)
@@ -1686,11 +1686,11 @@ udevSetupSystemDev(void)
     udevGetDMIData(&def->caps->data.system);
 #endif
 
-    dev = virNodeDeviceObjAssignDef(&driver->devs, def);
-    if (dev == NULL)
+    obj = virNodeDeviceObjAssignDef(&driver->devs, def);
+    if (obj == NULL)
         goto cleanup;
 
-    virNodeDeviceObjUnlock(dev);
+    virNodeDeviceObjUnlock(obj);
 
     ret = 0;
 
-- 
2.9.3

--
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]
  Powered by Linux