[PATCH 02/10] src: Use consistent error preservation and restoration calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux