Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/libvirt-stream.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c index ef83696bcd..fb646d0aef 100644 --- a/src/libvirt-stream.c +++ b/src/libvirt-stream.c @@ -622,12 +622,11 @@ virStreamSendAll(virStreamPtr stream, VIR_FREE(bytes); if (ret != 0) { - virErrorPtr orig_err = virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } @@ -794,12 +793,11 @@ int virStreamSparseSendAll(virStreamPtr stream, VIR_FREE(bytes); if (ret != 0) { - virErrorPtr orig_err = virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } @@ -900,12 +898,11 @@ virStreamRecvAll(virStreamPtr stream, VIR_FREE(bytes); if (ret != 0) { - virErrorPtr orig_err = virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } @@ -1034,12 +1031,11 @@ virStreamSparseRecvAll(virStreamPtr stream, VIR_FREE(bytes); if (ret != 0) { - virErrorPtr orig_err = virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list