Create local @obj and @def for the API's rather than referencing the
devs->objs[i][->def->]. It'll make future patches easier to read.
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
src/conf/virnodedeviceobj.c | 60 ++++++++++++++++++++++++++++-----------------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index fab1cfd..a9187be 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -172,12 +172,16 @@ virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
size_t i;
for (i = 0; i < devs->count; i++) {
- virNodeDeviceObjLock(devs->objs[i]);
- if ((devs->objs[i]->def->sysfs_path != NULL) &&
- (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) {
- return devs->objs[i];
+ virNodeDeviceObjPtr obj = devs->objs[i];
+ virNodeDeviceDefPtr def;
+
+ virNodeDeviceObjLock(obj);
+ def = obj->def;
+ if ((def->sysfs_path != NULL) &&
+ (STREQ(def->sysfs_path, sysfs_path))) {
+ return obj;
}
- virNodeDeviceObjUnlock(devs->objs[i]);
+ virNodeDeviceObjUnlock(obj);
}
return NULL;
@@ -191,10 +195,14 @@ virNodeDeviceObjListFindByName(virNodeDeviceObjListPtr devs,
size_t i;
for (i = 0; i < devs->count; i++) {
- virNodeDeviceObjLock(devs->objs[i]);
- if (STREQ(devs->objs[i]->def->name, name))
- return devs->objs[i];
- virNodeDeviceObjUnlock(devs->objs[i]);
+ virNodeDeviceObjPtr obj = devs->objs[i];
+ virNodeDeviceDefPtr def;
+
+ virNodeDeviceObjLock(obj);
+ def = obj->def;
+ if (STREQ(def->name, name))
+ return obj;
+ virNodeDeviceObjUnlock(obj);
}
return NULL;
@@ -209,14 +217,16 @@ virNodeDeviceObjListFindByWWNs(virNodeDeviceObjListPtr devs,
size_t i;
for (i = 0; i < devs->count; i++) {
+ virNodeDeviceObjPtr obj = devs->objs[i];
virNodeDevCapsDefPtr cap;
- virNodeDeviceObjLock(devs->objs[i]);
- if ((cap = virNodeDeviceFindFCCapDef(devs->objs[i])) &&
+
+ virNodeDeviceObjLock(obj);
+ if ((cap = virNodeDeviceFindFCCapDef(obj)) &&
STREQ_NULLABLE(cap->data.scsi_host.wwnn, parent_wwnn) &&
STREQ_NULLABLE(cap->data.scsi_host.wwpn, parent_wwpn) &&
- virNodeDeviceFindVPORTCapDef(devs->objs[i]))
- return devs->objs[i];
- virNodeDeviceObjUnlock(devs->objs[i]);
+ virNodeDeviceFindVPORTCapDef(obj))
+ return obj;
+ virNodeDeviceObjUnlock(obj);
}
return NULL;
@@ -230,13 +240,15 @@ virNodeDeviceObjListFindByFabricWWN(virNodeDeviceObjListPtr devs,
size_t i;
for (i = 0; i < devs->count; i++) {
+ virNodeDeviceObjPtr obj = devs->objs[i];
virNodeDevCapsDefPtr cap;
- virNodeDeviceObjLock(devs->objs[i]);
- if ((cap = virNodeDeviceFindFCCapDef(devs->objs[i])) &&
+
+ virNodeDeviceObjLock(obj);
+ if ((cap = virNodeDeviceFindFCCapDef(obj)) &&
STREQ_NULLABLE(cap->data.scsi_host.fabric_wwn, parent_fabric_wwn) &&
- virNodeDeviceFindVPORTCapDef(devs->objs[i]))
- return devs->objs[i];
- virNodeDeviceObjUnlock(devs->objs[i]);
+ virNodeDeviceFindVPORTCapDef(obj))
+ return obj;
+ virNodeDeviceObjUnlock(obj);
}
return NULL;
@@ -250,10 +262,12 @@ virNodeDeviceObjListFindByCap(virNodeDeviceObjListPtr devs,
size_t i;
for (i = 0; i < devs->count; i++) {
- virNodeDeviceObjLock(devs->objs[i]);
- if (virNodeDeviceObjHasCap(devs->objs[i], cap))
- return devs->objs[i];
- virNodeDeviceObjUnlock(devs->objs[i]);
+ virNodeDeviceObjPtr obj = devs->objs[i];
+
+ virNodeDeviceObjLock(obj);
+ if (virNodeDeviceObjHasCap(obj, cap))
+ return obj;
+ virNodeDeviceObjUnlock(obj);
}
return NULL;
--
2.9.4
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Sat, Jun 03, 2017 at 09:11:58AM -0400, John Ferlan wrote:
> Create local @obj and @def for the API's rather than referencing the
> devs->objs[i][->def->]. It'll make future patches easier to read.
>
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
> src/conf/virnodedeviceobj.c | 60 ++++++++++++++++++++++++++++-----------------
> 1 file changed, 37 insertions(+), 23 deletions(-)
>
> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
> index fab1cfd..a9187be 100644
> --- a/src/conf/virnodedeviceobj.c
> +++ b/src/conf/virnodedeviceobj.c
> @@ -172,12 +172,16 @@ virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
> size_t i;
>
> for (i = 0; i < devs->count; i++) {
> - virNodeDeviceObjLock(devs->objs[i]);
> - if ((devs->objs[i]->def->sysfs_path != NULL) &&
> - (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) {
> - return devs->objs[i];
> + virNodeDeviceObjPtr obj = devs->objs[i];
> + virNodeDeviceDefPtr def;
Although with good intension, I think having virNodeDeviceObjPtr obj = foo only
will make all the difference, thus dereferencing @def is IMHO not that much
more beneficial.
ACK with that.
Erik
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 06/30/2017 08:06 AM, Erik Skultety wrote:
> On Sat, Jun 03, 2017 at 09:11:58AM -0400, John Ferlan wrote:
>> Create local @obj and @def for the API's rather than referencing the
>> devs->objs[i][->def->]. It'll make future patches easier to read.
^^^^^^^^^ [1]
>>
>> Signed-off-by: John Ferlan <jferlan@redhat.com>
>> ---
>> src/conf/virnodedeviceobj.c | 60 ++++++++++++++++++++++++++++-----------------
>> 1 file changed, 37 insertions(+), 23 deletions(-)
>>
>> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
>> index fab1cfd..a9187be 100644
>> --- a/src/conf/virnodedeviceobj.c
>> +++ b/src/conf/virnodedeviceobj.c
>> @@ -172,12 +172,16 @@ virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
>> size_t i;
>>
>> for (i = 0; i < devs->count; i++) {
>> - virNodeDeviceObjLock(devs->objs[i]);
>> - if ((devs->objs[i]->def->sysfs_path != NULL) &&
>> - (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) {
>> - return devs->objs[i];
>> + virNodeDeviceObjPtr obj = devs->objs[i];
>> + virNodeDeviceDefPtr def;
>
> Although with good intension, I think having virNodeDeviceObjPtr obj = foo only
> will make all the difference, thus dereferencing @def is IMHO not that much
> more beneficial.
[1] I'm trying to avoid syntax such as:
devs->objs[i]->def->sysfs_path
or
objs->def->sysfs_path
If some day ->def is "owned-by" some vir*Object, then -> def would need
to be fetched, e.g. def = virObject*GetDef(obj), so this just makes that
future easier.
John
>
> ACK with that.
>
> Erik
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, Jun 30, 2017 at 01:08:22PM -0400, John Ferlan wrote:
>
>
> On 06/30/2017 08:06 AM, Erik Skultety wrote:
> > On Sat, Jun 03, 2017 at 09:11:58AM -0400, John Ferlan wrote:
> >> Create local @obj and @def for the API's rather than referencing the
> >> devs->objs[i][->def->]. It'll make future patches easier to read.
>
> ^^^^^^^^^ [1]
> >>
> >> Signed-off-by: John Ferlan <jferlan@redhat.com>
> >> ---
> >> src/conf/virnodedeviceobj.c | 60 ++++++++++++++++++++++++++++-----------------
> >> 1 file changed, 37 insertions(+), 23 deletions(-)
> >>
> >> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
> >> index fab1cfd..a9187be 100644
> >> --- a/src/conf/virnodedeviceobj.c
> >> +++ b/src/conf/virnodedeviceobj.c
> >> @@ -172,12 +172,16 @@ virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
> >> size_t i;
> >>
> >> for (i = 0; i < devs->count; i++) {
> >> - virNodeDeviceObjLock(devs->objs[i]);
> >> - if ((devs->objs[i]->def->sysfs_path != NULL) &&
> >> - (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) {
> >> - return devs->objs[i];
> >> + virNodeDeviceObjPtr obj = devs->objs[i];
> >> + virNodeDeviceDefPtr def;
> >
> > Although with good intension, I think having virNodeDeviceObjPtr obj = foo only
> > will make all the difference, thus dereferencing @def is IMHO not that much
> > more beneficial.
>
> [1] I'm trying to avoid syntax such as:
>
> devs->objs[i]->def->sysfs_path
>
> or
>
> objs->def->sysfs_path
>
> If some day ->def is "owned-by" some vir*Object, then -> def would need
> to be fetched, e.g. def = virObject*GetDef(obj), so this just makes that
> future easier.
Yeah, I'm realizing it was a pointless suggestion, strange I didn't even think
about that when I was looking at 10/12, you can disregard my previous comment
then...^good point btw.
ACK as is.
Erik
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.