snapshot: Allow NULL to virDomainSnapshotObjGetDef

Doing so can simplify some callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Eric Blake 2019-03-27 04:24:38 -05:00
parent 3d7c683a27
commit 6b90a84738
2 changed files with 2 additions and 2 deletions

View File

@ -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) {

View File

@ -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 */