83b1808 snapshot: Improve logic of virDomainMomentMoveChildren

Authored and Committed by ericb 5 years ago
    snapshot: Improve logic of virDomainMomentMoveChildren
    
    Even though Coverity can prove that 'last' is always set if the prior
    loop executed, gcc 8.0.1 cannot:
    
      CC       conf/libvirt_conf_la-virdomainmomentobjlist.lo
    ../../src/conf/virdomainmomentobjlist.c: In function 'virDomainMomentMoveChildren':
    ../../src/conf/virdomainmomentobjlist.c:178:19: error: 'last' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             last->sibling = to->first_child;
             ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
    Rewrite the loop to a form that should be easier for static analysis
    to work with.
    
    Fixes: ced0898f86bf
    Reported-by: Bjoern Walk <bwalk@linux.ibm.com>
    Signed-off-by: Eric Blake <eblake@redhat.com>
    Reviewed-by: Ján Tomko <jtomko@redhat.com>