提交 88669478 编写于 作者: J John Ferlan

tools: Use consistent error preservation and restoration calls

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: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 29565c50
......@@ -93,7 +93,7 @@ virshCatchDisconnect(virConnectPtr conn,
virErrorPtr error;
char *uri;
error = virSaveLastError();
virErrorPreserveLast(&error);
uri = virConnectGetURI(conn);
switch ((virConnectCloseReason) reason) {
......@@ -114,10 +114,7 @@ virshCatchDisconnect(virConnectPtr conn,
vshError(ctl, _(str), NULLSTR(uri));
VIR_FREE(uri);
if (error) {
virSetError(error);
virFreeError(error);
}
virErrorRestore(&error);
disconnected++;
vshEventDone(ctl);
}
......
......@@ -124,7 +124,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUSED,
if (reason == VIR_CONNECT_CLOSE_REASON_CLIENT)
return;
error = virSaveLastError();
virErrorPreserveLast(&error);
uri = virAdmConnectGetURI(conn);
switch ((virConnectCloseReason) reason) {
......@@ -146,10 +146,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUSED,
vshError(ctl, _(str), NULLSTR(uri));
VIR_FREE(uri);
if (error) {
virSetError(error);
virFreeError(error);
}
virErrorRestore(&error);
}
static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册