]> xenbits.xensource.com Git - libvirt.git/commitdiff
src: Use consistent error preservation and restoration calls
authorJohn Ferlan <jferlan@redhat.com>
Thu, 6 Dec 2018 17:32:18 +0000 (12:32 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 16 Oct 2019 19:24:40 +0000 (15:24 -0400)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libvirt-stream.c

index ef83696bcda78950060c6cadf200906507003faf..fb646d0aef4dc07ca40c31c9b91a6825e3e9e225 100644 (file)
@@ -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);
     }