[libvirt] [PATCH v7 02/23] snapshot: Allow NULL to virDomainSnapshotObjGetDef

Eric Blake posted 23 patches 6 years, 10 months ago
There is a newer version of this series
[libvirt] [PATCH v7 02/23] snapshot: Allow NULL to virDomainSnapshotObjGetDef
Posted by Eric Blake 6 years, 10 months ago
Doing so can simplify some callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 src/conf/virdomainsnapshotobjlist.h | 2 +-
 src/conf/snapshot_conf.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/virdomainsnapshotobjlist.h b/src/conf/virdomainsnapshotobjlist.h
index b83f7a4ba9..12b574b4ff 100644
--- a/src/conf/virdomainsnapshotobjlist.h
+++ b/src/conf/virdomainsnapshotobjlist.h
@@ -87,7 +87,7 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
 static inline virDomainSnapshotDefPtr
 virDomainSnapshotObjGetDef(virDomainMomentObjPtr obj)
 {
-    return (virDomainSnapshotDefPtr) obj->def;
+    return obj ? (virDomainSnapshotDefPtr) obj->def : NULL;
 }

 #endif /* LIBVIRT_VIRDOMAINSNAPSHOTOBJLIST_H */
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 4ce120451e..8e4f3d9410 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -967,7 +967,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
     }

     other = virDomainSnapshotFindByName(vm->snapshots, def->common.name);
-    otherdef = other ? virDomainSnapshotObjGetDef(other) : NULL;
+    otherdef = virDomainSnapshotObjGetDef(other);
     check_if_stolen = other && otherdef->common.dom;
     if (virDomainSnapshotRedefineValidate(def, domain->uuid, other, xmlopt,
                                           flags) < 0) {
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v7 02/23] snapshot: Allow NULL to virDomainSnapshotObjGetDef
Posted by Daniel P. Berrangé 6 years, 10 months ago
On Wed, Mar 27, 2019 at 05:07:13AM -0500, Eric Blake wrote:
> Doing so can simplify some callers.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  src/conf/virdomainsnapshotobjlist.h | 2 +-
>  src/conf/snapshot_conf.c            | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list