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

[libvirt] (no subject)



>From 7c2399ae2a65c60203b29ce02b694f80505ffc8c Mon Sep 17 00:00:00 2001
Message-Id: <7c2399ae2a65c60203b29ce02b694f80505ffc8c 1350037981 git cbley av-test de>
In-Reply-To: <cover 1350037981 git cbley av-test de>
References: <2DA6F4A3691599408358374D182280F9141CF6 xmb-rcd-x04 cisco com>	<cover 1350037981 git cbley av-test de>
From: cbley av-test de (Claudio Bley)
Date: Thu, 23 Aug 2012 14:51:28 +0200
Subject: [PATCH 11/15] Avoid unnecessary copying and calling virResetLastError.
To: libvir-list redhat com
Organization: AV-Test GmbH, Germany

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);
-- 
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


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