]> xenbits.xensource.com Git - libvirt.git/commit
error: preserve errno when saving last error
authorEric Blake <eblake@redhat.com>
Wed, 20 Jul 2011 23:07:59 +0000 (17:07 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 21 Jul 2011 13:24:33 +0000 (07:24 -0600)
commit979b784be21d901c13824665bb8b32889190ab62
treea2799ebb408803756d54754c5a3744d593c3bdb4
parent1468359f16b7b52c7ed815b2cb7af07762ca011a
error: preserve errno when saving last error

It is common to see the sequence:

virErrorPtr save_err = virSaveLastError();
// do cleanup
virSetError(save_err);
virFreeError(save_err);

on cleanup paths.  But for functions where it is desirable to
return the errno that caused failure, this sequence can clobber
that errno.  virFreeError was already safe; this makes the other
two functions in the sequence safe as well, assuming all goes
well (on OOM, errno will be clobbered, but then again, save_err
won't reflect the real error that happened, so you are no longer
preserving the real situation - that's life with OOM).

* src/util/virterror.c (virSaveLastError, virSetError): Preserve
errno.
src/util/virterror.c