[PATCH 11/15] Avoid unnecessary copying and calling virResetLastError.

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

 



Just use virGetLastError instead of virCopyLastError.

Calling virResetLastError is unnecessary because every public
libvirt function will first reset the error when being called.
---
 src/main/java/org/libvirt/ErrorHandler.java |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/libvirt/ErrorHandler.java b/src/main/java/org/libvirt/ErrorHandler.java
index 543829e..4dd7c90 100644
--- a/src/main/java/org/libvirt/ErrorHandler.java
+++ b/src/main/java/org/libvirt/ErrorHandler.java
@@ -20,14 +20,11 @@ public class ErrorHandler {
      * @throws LibvirtException
      */
     public static void processError(Libvirt libvirt) throws LibvirtException {
-        virError vError = new virError();
-        int errorCode = libvirt.virCopyLastError(vError);
-        if (errorCode > 0) {
+        virError vError = libvirt.virGetLastError();
+        if (vError != null) {
             Error error = new Error(vError);
-            libvirt.virResetLastError();
             /*
-             * FIXME: Don't throw exceptions for VIR_ERR_WARNING
-             * level errors
+             * Don't throw exceptions for VIR_ERR_WARNING level errors
              */
             if (error.getLevel() == Error.ErrorLevel.VIR_ERR_ERROR) {
                 throw new LibvirtException(error);
-- 
1.7.9.5

-- 
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>

Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

--
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]