On 02/23/2017 01:21 PM, Peter Krempa wrote: > Looks up a disk and it's corresponding backing chain element by node > name. > --- > src/qemu/qemu_domain.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > src/qemu/qemu_domain.h | 6 ++++++ > 2 files changed, 50 insertions(+) > > +virDomainDiskDefPtr > +qemuDomainDiskLookupByNodename(virDomainDefPtr def, > + const char *nodename, > + virStorageSourcePtr *src, > + unsigned int *idx) > +{ > + size_t i; > + unsigned int srcindex; > + virStorageSourcePtr tmp = NULL; Sometimes, I find it easier to do: if (!idx) idx = &srcindex; so that later on... > + > + if (src) > + *src = NULL; > + > + if (idx) > + *idx = 0; > + > + for (i = 0; i < def->ndisks; i++) { > + if ((tmp = virStorageSourceFindByNodeName(def->disks[i]->src, > + nodename, &srcindex))) { ...I can just pass 'idx' instead of '&srcindex' here... > + if (src) > + *src = tmp; > + > + if (idx) > + *idx = srcindex; ...and completely skip this conditional. But not a show-stopper. ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list