
On 3/28/19 10:18 AM, Ján Tomko wrote:
s/snapashot/snapshot/
I've been making that one a lot; will fix.
On Thu, Mar 28, 2019 at 09:05:31AM -0500, Eric Blake wrote:
Even though Coverity can prove that 'last' is always set if the prior loop executed, gcc 8.0.1 cannot:
+++ b/src/conf/virdomainmomentobjlist.c @@ -164,18 +164,17 @@ void virDomainMomentMoveChildren(virDomainMomentObjPtr from, virDomainMomentObjPtr to) { - virDomainMomentObjPtr child; - virDomainMomentObjPtr last; + virDomainMomentObjPtr child = from->first_child;
- if (!from->first_child) - return;
From the code-change point-of view, by removing this condition,
- for (child = from->first_child; child; child = child->sibling) { + while (child) { child->parent = to; - if (!child->sibling) - last = child; + if (!child->sibling) { + child->sibling = to->first_child; + break; + } + child = child->sibling; } to->nchildren += from->nchildren; - last->sibling = to->first_child; to->first_child = from->first_child;
this possibly erases 'to->first_child' if 'from' does not have any.
Oh, good point. I'll keep the early exit for (!from->nchildren) then,
But the callers are reasonable and only call this if (from->nchildren)
because I'm not certain that all future callers will be reasonable.
from->nchildren = 0; from->first_child = NULL;
Reviewed-by: Ján Tomko <jtomko@redhat.com>
I'll go ahead and push this one with those fixes. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org