From nobody Sun May 5 09:40:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525521901093774.0046819144694; Sat, 5 May 2018 05:05:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D3303002398; Sat, 5 May 2018 12:04:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 80CCE17F86; Sat, 5 May 2018 12:04:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0FEAD180BADC; Sat, 5 May 2018 12:04:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w45C4pfq016052 for ; Sat, 5 May 2018 08:04:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BC9E60474; Sat, 5 May 2018 12:04:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93D186031B for ; Sat, 5 May 2018 12:04:48 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B4C885376 for ; Sat, 5 May 2018 12:04:38 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a67so7552289wmf.3 for ; Sat, 05 May 2018 05:04:37 -0700 (PDT) Received: from localhost.localdomain ([212.92.119.143]) by smtp.gmail.com with ESMTPSA id g21-v6sm7702047edm.27.2018.05.05.05.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 May 2018 05:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OIWAt2ZijpTtD9DbqmQBiadOaMRALS5R+qRwwuBU6UY=; b=FiHVr/Sy7Gf0J+gq8ZzuzIdDaqQw1t2SOv0b6x04U0N++NaTCOtx9ftSaKAxPrb5Cu OjVh4BrJZA2NCknogWUYht7Q9NseDkvs5e9US3+zmhN1+dra559Xel/aydgM+NoEPTwe VNSgoZc1a1DwX74JW94E+fSetsf2yn15I7GQbCKCzyyMjhPnMaR7YGnlx7VUAJ6IM4mF +ZQDjw2slM5qdFUe+keR/k9pBNmDrY3oh/JvOhsARsYs4lTFDDRO8BuFWpOvmfwAz6wG ya7uUXMqVhLMH16dDbbPReCWSzgAfsOOBpKcke30cNLOunl8i3uxFhhKEZz07aopXuLb WYDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OIWAt2ZijpTtD9DbqmQBiadOaMRALS5R+qRwwuBU6UY=; b=kLQBT12p6O+NChmc1a5SdttrNBvJQuDmOFD7kr/GA4gsZteGxgWr68/LokNQsAcO/7 3YBvnpDnPj730Iu+UcPPNo1RydJxpZ+nJeRQxLIVhKn/r4KI7tgvVdjjhWeS9cOrppgY vYcVqMLe7o0EwI5FMwaxTgk1+uRGpm5pNlZIybBgwz66sDJpt3Yu4si4wb6sxwPGjTrb kspZJQpSXv15Q2htdTZ7rV1aPULOr8TgCD2J62Rjla8PfN0p6iT5SueRmBo598PkwiX0 ByfxlaVA6glngqnSp7IUU2/lduHeOdnApvQS3jwQ0VPBGBXvG5mtMfiuhxGlLwBKSd1k Acpw== X-Gm-Message-State: ALQs6tDMwjR0tDpRnzy3thB08Iid4OWBWq3gczgkZkF6F+rWjy3tgdly zRsEpmGpztgIsPwS0OxEAYcZgA== X-Google-Smtp-Source: AB8JxZq36173Ric8QXcsjxFUFYt9xdmvixroL1wzyD8Fl5KNu54zA+GMY0fYTb+r8935wDNh5EBtMg== X-Received: by 2002:a50:8c8c:: with SMTP id q12-v6mr40596488edq.17.1525521876642; Sat, 05 May 2018 05:04:36 -0700 (PDT) From: ramyelkest To: libvir-list@redhat.com Date: Sat, 5 May 2018 13:04:19 +0100 Message-Id: <1525521861-32624-2-git-send-email-ramyelkest@gmail.com> In-Reply-To: <1525521861-32624-1-git-send-email-ramyelkest@gmail.com> References: <1525521861-32624-1-git-send-email-ramyelkest@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 05 May 2018 12:04:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 05 May 2018 12:04:38 +0000 (UTC) for IP:'74.125.82.65' DOMAIN:'mail-wm0-f65.google.com' HELO:'mail-wm0-f65.google.com' FROM:'ramyelkest@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.82.65 mail-wm0-f65.google.com 74.125.82.65 mail-wm0-f65.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: ramyelkest Subject: [libvirt] [PATCH 1/3] util: cleanup: using virGetLastErrorMessage instead of err->message X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Sat, 05 May 2018 12:04:59 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Ramy Elkest Reviewed-by: Erik Skultety --- src/util/virfilecache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index dab7216..96ae96d 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -157,9 +157,8 @@ virFileCacheLoad(virFileCachePtr cache, } =20 if (!(loadData =3D cache->handlers.loadFile(file, name, cache->priv)))= { - virErrorPtr err =3D virGetLastError(); VIR_WARN("Failed to load cached data from '%s' for '%s': %s", - file, name, err ? NULLSTR(err->message) : "unknown error"= ); + file, name, virGetLastErrorMessage()); virResetLastError(); ret =3D 0; goto cleanup; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 09:40:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525521905940836.1985948602862; Sat, 5 May 2018 05:05:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C5294E90C; Sat, 5 May 2018 12:04:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 751B65C3FD; Sat, 5 May 2018 12:04:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9D09A5BBE5; Sat, 5 May 2018 12:04:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w45C4qZW016065 for ; Sat, 5 May 2018 08:04:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id E0CCC30012A3; Sat, 5 May 2018 12:04:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9F42309128B for ; Sat, 5 May 2018 12:04:50 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E287F3680B for ; Sat, 5 May 2018 12:04:38 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id a67so7552318wmf.3 for ; Sat, 05 May 2018 05:04:38 -0700 (PDT) Received: from localhost.localdomain ([212.92.119.143]) by smtp.gmail.com with ESMTPSA id g21-v6sm7702047edm.27.2018.05.05.05.04.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 May 2018 05:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/uC3uzbdHTORGkcX/ZAo0o+oVI4BYn3I/tcGqXvLBKE=; b=ajgSUykVhp6VI3v9F/sb6DaZYJimT++JinkATY37ZjIaooOqdH6oOsdD5bZoDD3v/5 EBNge6A2ywwvWn+P/JVCS8oRP9o3U5AVTSSXH+htAAIvOpQEg2pW623NMYdqlgUp0Dxz get4L558ii3Rzpba/f2Ry/5VPnIQpkZSWgRTzntkupeSoxwl4sQEofCi+9bQgsd0QzBx ZIK5axOUFftEhwlJFSMmhEG45OjJahb9HHySyonXJTbmshsV06nAbdz0DdgeJdoZHHW2 PPwcl76YSKDzja+xs15EcAqwbyN/JaK+O+s/Nbh74fHkW3w3EOQk36hSaj1Am/XeUjLI 2gPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/uC3uzbdHTORGkcX/ZAo0o+oVI4BYn3I/tcGqXvLBKE=; b=CttbAs3avhr0O45t05yfCk73EvGQwEdzzFazCpsW5IV5zN9bECIJvMMaY3MGgS9tlu ish/P3mBC56qhhG6Bv0Sc850mS+2MqLRhiG6/Gu0iujiSv/fZmZT7hq+DT2pnjJgPRWF yaIUVlt3DfqKEVWSohKqrQcwPzzvj+39N3e6gaL4f/myCoOB3wOWqRxg8VWYDGYZrk22 zVig2gUiRT3y8gI/jCOALK+jjU1vy8noCTT2qB21EDfs1THHBjHSxz51WFA7ChSaugNV JffqQ0a6KravUGEGQuI3clOsi9pfrmdJkEKDPkPRkVGK0S2kW+Cd4SCsvhG28Rcy0dYc pTjQ== X-Gm-Message-State: ALQs6tBATmAfdwECypcckr8qqQopxw7B/53SQabAba/9d1lfF/Sg2Bd9 Osx3/YBc0kfwfrtrSsfn0JpR2g== X-Google-Smtp-Source: AB8JxZpE4dHB+eR4LuIDEnfnrDPe1r79gnovkMfSiWMBMVUZyh430Fnc+hp7htwqio3uiFJm1QSC5Q== X-Received: by 2002:a50:d59e:: with SMTP id v30-v6mr40731107edi.167.1525521877504; Sat, 05 May 2018 05:04:37 -0700 (PDT) From: ramyelkest To: libvir-list@redhat.com Date: Sat, 5 May 2018 13:04:20 +0100 Message-Id: <1525521861-32624-3-git-send-email-ramyelkest@gmail.com> In-Reply-To: <1525521861-32624-1-git-send-email-ramyelkest@gmail.com> References: <1525521861-32624-1-git-send-email-ramyelkest@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 05 May 2018 12:04:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 05 May 2018 12:04:39 +0000 (UTC) for IP:'74.125.82.66' DOMAIN:'mail-wm0-f66.google.com' HELO:'mail-wm0-f66.google.com' FROM:'ramyelkest@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.82.66 mail-wm0-f66.google.com 74.125.82.66 mail-wm0-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: ramyelkest Subject: [libvirt] [PATCH 2/3] util: added virGetLastErrorCode/Domain X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 05 May 2018 12:05:04 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Many places in the code call virGetLastError() just to check the raised error code, or domain. However virGetLastError() can return NULL, so the code has to check for that first. This patch therefore introduces virGetLasErrorCode/Domain function which always returns a valid error code/domain respectively, thus dropping the need to perform any checks on the error object. Signed-off-by: Ramy Elkest Reviewed-by: Erik Skultety --- include/libvirt/virterror.h | 2 ++ src/libvirt_public.syms | 6 ++++++ src/util/virerror.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 3e7c7a0..5e58b6a 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -344,6 +344,8 @@ void virResetLastError (void); void virResetError (virErrorPtr err); void virFreeError (virErrorPtr err); =20 +int virGetLastErrorCode (void); +int virGetLastErrorDomain (void); const char * virGetLastErrorMessage (void); =20 virErrorPtr virConnGetLastError (virConnectPtr conn); diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 95df3a0..85b6b6d 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -785,4 +785,10 @@ LIBVIRT_4.1.0 { virStoragePoolLookupByTargetPath; } LIBVIRT_3.9.0; =20 +LIBVIRT_4.4.0 { + global: + virGetLastErrorCode; + virGetLastErrorDomain; +} LIBVIRT_4.1.0; + # .... define new API here using predicted next version number .... diff --git a/src/util/virerror.c b/src/util/virerror.c index c000b00..842fc49 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -272,6 +272,48 @@ virGetLastError(void) =20 =20 /** + * virGetLastErrorCode: + * + * Get the most recent error code + * + * The error object is kept in thread local storage, so separate + * threads can safely access this concurrently. + * + * Returns the most recent error code in this thread, + * or VIR_ERR_OK if none is set + */ +int +virGetLastErrorCode(void) +{ + virErrorPtr err =3D virLastErrorObject(); + if (!err) + return VIR_ERR_OK; + return err->code; +} + + +/** + * virGetLastErrorDomain: + * + * Get the most recent error domain + * + * The error object is kept in thread local storage, so separate + * threads can safely access this concurrently. + * + * Returns the most recent error code in this thread, + * or VIR_FROM_NONE if none is set + */ +int +virGetLastErrorDomain(void) +{ + virErrorPtr err =3D virLastErrorObject(); + if (!err) + return VIR_FROM_NONE; + return err->domain; +} + + +/** * virGetLastErrorMessage: * * Get the most recent error message --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 09:40:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525522296839720.8618815209992; Sat, 5 May 2018 05:11:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ABCF356C2; Sat, 5 May 2018 12:11:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7218EA037A; Sat, 5 May 2018 12:11:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5E9545BBE6; Sat, 5 May 2018 12:11:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w45C4sBP016080 for ; Sat, 5 May 2018 08:04:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id D7AA41001F4E; Sat, 5 May 2018 12:04:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D08DA1001F43 for ; Sat, 5 May 2018 12:04:52 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46BF830001DA for ; Sat, 5 May 2018 12:04:40 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id f8-v6so8902665wmc.4 for ; Sat, 05 May 2018 05:04:40 -0700 (PDT) Received: from localhost.localdomain ([212.92.119.143]) by smtp.gmail.com with ESMTPSA id g21-v6sm7702047edm.27.2018.05.05.05.04.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 May 2018 05:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=elnaSvYAD0p6SvYX9s6QFr672Mj0oeUdl6RmqPp0dNQ=; b=RVtEVrMsEoCm/AbiwuHOV9HoT3e+HUrHewQQ7AeWj7CvT7rQRc/9RLyucZcUBjLBOy 3GLyLEM2bk5O/HLoWio3Zw/J1AQRbGfkfpV4yjgliI3H7KZR26wjNB6y/Tp3FNsKVSW6 lkBUTFXJwWkZA3HmRo/ADPLvzZel7PIsIboyfg0kvTifYf4hhLks23S6npXoD79ZAO0Y n5cxsfYnlQ/fgS7NlRs3hHbO8gXuQXHFPbWXUe1v0KTugQD7dVjJCG8cenJma+Jxd+PK PJzndfaA0sPpTT00DAfRpgPKMtO8hCsiahcjjnPWFouR1WkWHAAuP5pMNbCmswxHfk1d +JmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=elnaSvYAD0p6SvYX9s6QFr672Mj0oeUdl6RmqPp0dNQ=; b=Ia0VFGx+GDCEq1zZXynFaFRtFNdhGfFUbBmVvDHUbWa4MiQui9wjs2wX4ZNG4N7Q3g ICOswwKn5RIXV25LFih0Uov/97ND4RWW8JutCo9xqhjPfR7Yz4sZGBfVZ39KGlx/m36r 0UWLxwCrdjHhkh8dqIgc2iU6954cCZeG0Ge1w1ElniQzNSkBoIjwmO246ODk+AjJP4Uu clQ5Y6/WfThx7m9PB898eE3UBfgHaMwFHW5HA7ClLCHGmk005KcOb/qsvM0ohcnko93s HXJDebfJ5WSGlGgYLUBqL/w4zs+9TvEL/YyHbVThHpVChiOU9V4dZTpiCQF0cQU/9lRg o72A== X-Gm-Message-State: ALQs6tCMubBvz3D7ArHkHpJkG6Ls+7K2suEdIqnNPRxI2wPimSzReCXp eDFaPxE5Z/CK5UNDWeqIY5rYAw== X-Google-Smtp-Source: AB8JxZpWD47tR5gqvcbWAJUXYCwsf31FiMTGTGYIMh6FIt5nwfGRWRtiyN10q7tNS4lK7HvbklyM+Q== X-Received: by 2002:a50:d845:: with SMTP id v5-v6mr21400818edj.95.1525521878657; Sat, 05 May 2018 05:04:38 -0700 (PDT) From: ramyelkest To: libvir-list@redhat.com Date: Sat, 5 May 2018 13:04:21 +0100 Message-Id: <1525521861-32624-4-git-send-email-ramyelkest@gmail.com> In-Reply-To: <1525521861-32624-1-git-send-email-ramyelkest@gmail.com> References: <1525521861-32624-1-git-send-email-ramyelkest@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sat, 05 May 2018 12:04:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sat, 05 May 2018 12:04:40 +0000 (UTC) for IP:'74.125.82.65' DOMAIN:'mail-wm0-f65.google.com' HELO:'mail-wm0-f65.google.com' FROM:'ramyelkest@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.82.65 mail-wm0-f65.google.com 74.125.82.65 mail-wm0-f65.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: ramyelkest Subject: [libvirt] [PATCH 3/3] all: replacing virGetLastError with virGetLastErrorCode where we can X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 05 May 2018 12:11:35 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Replaced instances where we called virGetLastError just to either get the code or to check if an error exists with virGetLastErrorCode to avoid a validity pre-check. Signed-off-by: Ramy Elkest Reviewed-by: Erik Skultety --- src/locking/lock_driver_lockd.c | 3 +-- src/lxc/lxc_controller.c | 4 +--- src/qemu/qemu_agent.c | 3 +-- src/qemu/qemu_conf.c | 3 +-- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 12 ++++++------ src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_migration.c | 4 ++-- src/qemu/qemu_monitor.c | 5 ++--- src/qemu/qemu_monitor_json.c | 2 +- src/qemu/qemu_process.c | 4 ++-- src/remote/remote_driver.c | 3 +-- src/rpc/virnetclient.c | 2 +- src/rpc/virnetlibsshsession.c | 4 +--- src/util/virmodule.c | 3 +-- src/util/virxml.c | 4 ++-- tests/commandtest.c | 2 +- tests/testutils.c | 6 ++---- tests/virhostcputest.c | 2 +- tests/virstoragetest.c | 8 ++++---- tools/virsh-domain-monitor.c | 7 +++---- tools/virsh-domain.c | 4 +--- tools/virsh-util.c | 3 +-- tools/vsh.c | 2 +- 24 files changed, 39 insertions(+), 55 deletions(-) diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index c3fc18a..957a963 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -302,8 +302,7 @@ static int virLockManagerLockDaemonSetupLockspace(const= char *path) 0, NULL, NULL, NULL, (xdrproc_t)xdr_virLockSpaceProtocolCreateL= ockSpaceArgs, (char*)&args, (xdrproc_t)xdr_void, NULL) < 0) { - virErrorPtr err =3D virGetLastError(); - if (err && err->code =3D=3D VIR_ERR_OPERATION_INVALID) { + if (virGetLastErrorCode() =3D=3D VIR_ERR_OPERATION_INVALID) { /* The lockspace already exists */ virResetLastError(); rv =3D 0; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index d5636b8..e1ee864 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1297,7 +1297,6 @@ static void virLXCControllerConsoleIO(int watch, int = fd, int events, void *opaqu */ static int virLXCControllerMain(virLXCControllerPtr ctrl) { - virErrorPtr err; int rc =3D -1; size_t i; =20 @@ -1349,8 +1348,7 @@ static int virLXCControllerMain(virLXCControllerPtr c= trl) =20 virNetDaemonRun(ctrl->daemon); =20 - err =3D virGetLastError(); - if (!err || err->code =3D=3D VIR_ERR_OK) + if (!virGetLastErrorCode()) rc =3D wantReboot ? 1 : 0; =20 cleanup: diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 4df1bde..1fb31a7 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -686,8 +686,7 @@ qemuAgentIO(int watch, int fd, int events, void *opaque) /* Already have an error, so clear any new error */ virResetLastError(); } else { - virErrorPtr err =3D virGetLastError(); - if (!err) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error while processing monitor IO")); virCopyLastError(&mon->lastError); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index bfbb572..a09532d 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -297,8 +297,7 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) if (privileged && virFileFindHugeTLBFS(&cfg->hugetlbfs, &cfg->nhugetlbfs) < 0) { /* This however is not implemented on all platforms. */ - virErrorPtr err =3D virGetLastError(); - if (err && err->code !=3D VIR_ERR_NO_SUPPORT) + if (virGetLastErrorCode() !=3D VIR_ERR_NO_SUPPORT) goto error; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 727ea33..128f1a0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6063,7 +6063,7 @@ int qemuDomainObjExitMonitor(virQEMUDriverPtr driver, { qemuDomainObjExitMonitorInternal(driver, obj); if (!virDomainObjIsActive(obj)) { - if (!virGetLastError()) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("domain is no longer running")); return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 83fc191..bd776e0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1929,7 +1929,7 @@ static int qemuDomainResume(virDomainPtr dom) if (qemuProcessStartCPUs(driver, vm, VIR_DOMAIN_RUNNING_UNPAUSED, QEMU_ASYNC_JOB_NONE) < 0) { - if (virGetLastError() =3D=3D NULL) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resume operation failed")); goto endjob; @@ -3209,7 +3209,7 @@ qemuFileWrapperFDClose(virDomainObjPtr vm, ret =3D virFileWrapperFdClose(fd); virObjectLock(vm); if (!virDomainObjIsActive(vm)) { - if (!virGetLastError()) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("domain is no longer running")); ret =3D -1; @@ -3991,7 +3991,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT= _SUSPENDED, VIR_DOMAIN_EVENT= _SUSPENDED_API_ERROR); - if (virGetLastError() =3D=3D NULL) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resuming after dump failed")); } @@ -6638,7 +6638,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, if (qemuProcessStartCPUs(driver, vm, VIR_DOMAIN_RUNNING_RESTORED, asyncJob) < 0) { - if (virGetLastError() =3D=3D NULL) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to resume domain")); goto cleanup; @@ -14084,7 +14084,7 @@ qemuDomainSnapshotCreateActiveInternal(virQEMUDrive= rPtr driver, event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_API_ER= ROR); - if (virGetLastError() =3D=3D NULL) { + if (!virGetLastErrorCode()) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resuming after snapshot failed")); } @@ -15048,7 +15048,7 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDrive= rPtr driver, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_API_ER= ROR); qemuDomainEventQueue(driver, event); - if (virGetLastError() =3D=3D NULL) { + if (!virGetLastErrorCode()) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resuming after snapshot failed")); } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9ca8e66..c755aab 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -212,7 +212,7 @@ qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver, if (rc > 0) { /* the caller called qemuMonitorEjectMedia which usually repor= ts an * error. Report the failure in an off-chance that it didn't. = */ - if (!virGetLastError()) { + if (!virGetLastErrorCode()) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("timed out waiting for disk tray status u= pdate")); } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 7602a30..bf4a144 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4944,7 +4944,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, inPostCopy ? VIR_DOMAIN_RUNNING_POSTCOPY : VIR_DOMAIN_RUNNING_MIGRATED, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) { - if (virGetLastError() =3D=3D NULL) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("resume operation failed")); /* Need to save the current error, in case shutting @@ -5082,7 +5082,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, /* Set a special error if Finish is expected to return NULL as a resul= t of * successful call with retcode !=3D 0 */ - if (retcode !=3D 0 && !dom && !virGetLastError()) + if (retcode !=3D 0 && !dom && !virGetLastErrorCode()) virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); return dom; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 3918791..f68fd47 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -752,8 +752,7 @@ qemuMonitorIO(int watch, int fd, int events, void *opaq= ue) /* Already have an error, so clear any new error */ virResetLastError(); } else { - virErrorPtr err =3D virGetLastError(); - if (!err) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error while processing monitor IO")); virCopyLastError(&mon->lastError); @@ -1032,7 +1031,7 @@ qemuMonitorClose(qemuMonitorPtr mon) /* Propagate existing monitor error in case the current thread has no * error set. */ - if (mon->lastError.code !=3D VIR_ERR_OK && !virGetLastError()) + if (mon->lastError.code !=3D VIR_ERR_OK && !virGetLastErrorCode()) virSetError(&mon->lastError); =20 virObjectUnlock(mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8176175..306067b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4338,7 +4338,7 @@ qemuMonitorJSONDiskNameLookup(qemuMonitorPtr mon, } /* Guarantee an error when returning NULL, but don't override a * more specific error if one was already generated. */ - if (!ret && !virGetLastError()) + if (!ret && !virGetLastErrorCode()) virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find backing name for device %s"), device); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 37876b8..b8f195c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -558,7 +558,7 @@ qemuProcessFakeReboot(void *opaque) if (qemuProcessStartCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0) { - if (virGetLastError() =3D=3D NULL) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("resume operation failed")); goto endjob; @@ -6259,7 +6259,7 @@ qemuProcessFinishStartup(virQEMUDriverPtr driver, if (qemuProcessStartCPUs(driver, vm, VIR_DOMAIN_RUNNING_BOOTED, asyncJob) < 0) { - if (!virGetLastError()) + if (!virGetLastErrorCode()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resume operation failed")); goto cleanup; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 95437b4..e670e16 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3672,8 +3672,7 @@ remoteAuthenticate(virConnectPtr conn, struct private= _data *priv, (xdrproc_t) xdr_void, (char *) NULL, (xdrproc_t) xdr_remote_auth_list_ret, (char *) &ret); if (err < 0) { - virErrorPtr verr =3D virGetLastError(); - if (verr && verr->code =3D=3D VIR_ERR_NO_SUPPORT) { + if (virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) { /* Missing RPC - old server - ignore */ virResetLastError(); return 0; diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 6bbc984..b4d8fb2 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1958,7 +1958,7 @@ static int virNetClientIO(virNetClientPtr client, virNetClientIOUpdateCallback(client, true); =20 if (rv =3D=3D 0 && - virGetLastError()) + virGetLastErrorCode()) rv =3D -1; =20 cleanup: diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 309e8a9..b2cb5c1 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -499,9 +499,7 @@ virNetLibsshImportPrivkey(virNetLibsshSessionPtr sess, err =3D SSH_AUTH_ERROR; goto error; } else if (ret =3D=3D SSH_ERROR) { - virErrorPtr vir_err =3D virGetLastError(); - - if (!vir_err || !vir_err->code) { + if (!virGetLastErrorCode()) { virReportError(VIR_ERR_AUTH_FAILED, _("error while opening private key '%s', wrong " "passphrase?"), diff --git a/src/util/virmodule.c b/src/util/virmodule.c index ff8c227..9d7d249 100644 --- a/src/util/virmodule.c +++ b/src/util/virmodule.c @@ -123,8 +123,7 @@ virModuleLoad(const char *path, if ((*regsym)() < 0) { /* regsym() should report an error itself, but lets * just make sure */ - virErrorPtr err =3D virGetLastError(); - if (err =3D=3D NULL) { + if (!virGetLastErrorCode()) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to execute symbol '%s' in module '%s'= "), regfunc, path); diff --git a/src/util/virxml.c b/src/util/virxml.c index 6e87605..b5caee7 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -708,7 +708,7 @@ catchXMLError(void *ctx, const char *msg ATTRIBUTE_UNUS= ED, ...) =20 /* conditions for error printing */ if (!ctxt || - (virGetLastError() !=3D NULL) || + (virGetLastErrorCode()) || ctxt->input =3D=3D NULL || ctxt->lastError.level !=3D XML_ERR_FATAL || ctxt->lastError.message =3D=3D NULL) @@ -845,7 +845,7 @@ virXMLParseHelper(int domcode, xmlFreeDoc(xml); xml =3D NULL; =20 - if (virGetLastError() =3D=3D NULL) { + if (!virGetLastErrorCode()) { virGenericReportError(domcode, VIR_ERR_XML_ERROR, "%s", _("failed to parse xml document")); } diff --git a/tests/commandtest.c b/tests/commandtest.c index ad81c2a..3bb7220 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -127,7 +127,7 @@ static int test0(const void *unused ATTRIBUTE_UNUSED) if (virCommandRun(cmd, NULL) =3D=3D 0) goto cleanup; =20 - if (virGetLastError() =3D=3D NULL) + if (!virGetLastErrorCode()) goto cleanup; =20 virResetLastError(); diff --git a/tests/testutils.c b/tests/testutils.c index 4b13d11..f0719c8 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -178,8 +178,7 @@ virTestRun(const char *title, =20 virResetLastError(); ret =3D body(data); - virErrorPtr err =3D virGetLastError(); - if (err) { + if (virGetLastErrorCode()) { if (virTestGetVerbose() || virTestGetDebug()) virDispatchError(NULL); } @@ -258,8 +257,7 @@ virTestRun(const char *title, fprintf(stderr, " alloc %zu failed but no err status\n", i= + 1); # endif } else { - virErrorPtr lerr =3D virGetLastError(); - if (!lerr) { + if (!virGetLastErrorCode()) { # if 0 fprintf(stderr, " alloc %zu failed but no error report= \n", i + 1); # endif diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index cb318df..091dd59 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -49,7 +49,7 @@ linuxTestCompareFiles(const char *cpuinfofile, &nodeinfo.nodes, &nodeinfo.sockets, &nodeinfo.cores, &nodeinfo.threads)= < 0) { if (virTestGetDebug()) { - if (virGetLastError()) + if (virGetLastErrorCode()) VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage()); } VIR_FORCE_FCLOSE(cpuinfo); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 0e11602..de68ea0 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -333,7 +333,7 @@ testStorageChain(const void *args) goto cleanup; } if (data->flags & EXP_WARN) { - if (!virGetLastError()) { + if (!virGetLastErrorCode()) { fprintf(stderr, "call should have warned\n"); goto cleanup; } @@ -343,7 +343,7 @@ testStorageChain(const void *args) goto cleanup; } } else { - if (virGetLastError()) { + if (virGetLastErrorCode()) { fprintf(stderr, "call should not have warned\n"); goto cleanup; } @@ -449,13 +449,13 @@ testStorageLookup(const void *args) idx, NULL); =20 if (!data->expResult) { - if (!virGetLastError()) { + if (!virGetLastErrorCode()) { fprintf(stderr, "call should have failed\n"); ret =3D -1; } virResetLastError(); } else { - if (virGetLastError()) { + if (virGetLastErrorCode()) { fprintf(stderr, "call should not have warned\n"); ret =3D -1; } diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 8e07177..32099cb 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -63,7 +63,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, unsigned int flags) { char *desc =3D NULL; - virErrorPtr err =3D NULL; xmlDocPtr doc =3D NULL; xmlXPathContextPtr ctxt =3D NULL; int type; @@ -76,15 +75,15 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr= dom, bool title, if ((desc =3D virDomainGetMetadata(dom, type, NULL, flags))) { return desc; } else { - err =3D virGetLastError(); + int errCode =3D virGetLastErrorCode(); =20 - if (err && err->code =3D=3D VIR_ERR_NO_DOMAIN_METADATA) { + if (errCode =3D=3D VIR_ERR_NO_DOMAIN_METADATA) { desc =3D vshStrdup(ctl, ""); vshResetLibvirtError(); return desc; } =20 - if (err && err->code !=3D VIR_ERR_NO_SUPPORT) + if (errCode !=3D VIR_ERR_NO_SUPPORT) return desc; } =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 598d2fa..e9972b9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -94,9 +94,7 @@ virshDomainDefine(virConnectPtr conn, const char *xml, un= signed int flags) * try again. */ if (!dom) { - virErrorPtr err =3D virGetLastError(); - if (err && - (err->code =3D=3D VIR_ERR_NO_SUPPORT) && + if ((virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) && (flags =3D=3D VIR_DOMAIN_DEFINE_VALIDATE)) dom =3D virDomainDefineXML(conn, xml); } diff --git a/tools/virsh-util.c b/tools/virsh-util.c index 44be3ad..aa88397 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -123,8 +123,7 @@ virshDomainState(vshControl *ctl, if (!priv->useGetInfo) { int state; if (virDomainGetState(dom, &state, reason, 0) < 0) { - virErrorPtr err =3D virGetLastError(); - if (err && err->code =3D=3D VIR_ERR_NO_SUPPORT) + if (virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) priv->useGetInfo =3D true; else return -1; diff --git a/tools/vsh.c b/tools/vsh.c index 73ec007..8f8ffb0 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -266,7 +266,7 @@ vshSaveLibvirtHelperError(void) if (last_error) return; =20 - if (!virGetLastError()) + if (!virGetLastErrorCode()) return; =20 vshSaveLibvirtError(); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list