mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
all: Replace virGetLastError with virGetLastErrorCode where we can
Replace instances where we previously 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 <ramyelkest@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
committed by
Erik Skultety
parent
50e96bb2a1
commit
2b6667abbf
@@ -60,7 +60,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
|
||||
unsigned int flags)
|
||||
{
|
||||
char *desc = NULL;
|
||||
virErrorPtr err = NULL;
|
||||
xmlDocPtr doc = NULL;
|
||||
xmlXPathContextPtr ctxt = NULL;
|
||||
int type;
|
||||
@@ -73,15 +72,15 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
|
||||
if ((desc = virDomainGetMetadata(dom, type, NULL, flags))) {
|
||||
return desc;
|
||||
} else {
|
||||
err = virGetLastError();
|
||||
int errCode = virGetLastErrorCode();
|
||||
|
||||
if (err && err->code == VIR_ERR_NO_DOMAIN_METADATA) {
|
||||
if (errCode == VIR_ERR_NO_DOMAIN_METADATA) {
|
||||
desc = vshStrdup(ctl, "");
|
||||
vshResetLibvirtError();
|
||||
return desc;
|
||||
}
|
||||
|
||||
if (err && err->code != VIR_ERR_NO_SUPPORT)
|
||||
if (errCode != VIR_ERR_NO_SUPPORT)
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,7 @@ virshDomainDefine(virConnectPtr conn, const char *xml, unsigned int flags)
|
||||
* try again.
|
||||
*/
|
||||
if (!dom) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
if (err &&
|
||||
(err->code == VIR_ERR_NO_SUPPORT) &&
|
||||
if ((virGetLastErrorCode() == VIR_ERR_NO_SUPPORT) &&
|
||||
(flags == VIR_DOMAIN_DEFINE_VALIDATE))
|
||||
dom = virDomainDefineXML(conn, xml);
|
||||
}
|
||||
|
||||
+1
-2
@@ -123,8 +123,7 @@ virshDomainState(vshControl *ctl,
|
||||
if (!priv->useGetInfo) {
|
||||
int state;
|
||||
if (virDomainGetState(dom, &state, reason, 0) < 0) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
if (err && err->code == VIR_ERR_NO_SUPPORT)
|
||||
if (virGetLastErrorCode() == VIR_ERR_NO_SUPPORT)
|
||||
priv->useGetInfo = true;
|
||||
else
|
||||
return -1;
|
||||
|
||||
+1
-1
@@ -266,7 +266,7 @@ vshSaveLibvirtHelperError(void)
|
||||
if (last_error)
|
||||
return;
|
||||
|
||||
if (!virGetLastError())
|
||||
if (virGetLastErrorCode() == VIR_ERR_OK)
|
||||
return;
|
||||
|
||||
vshSaveLibvirtError();
|
||||
|
||||
Reference in New Issue
Block a user