mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Simplify vshTableRowAppend() calling in cmdList(), part one
All calls to vshTableRowAppend() inside of cmdList() share couple of same arguments: domain ID, domain name and domain state. While the first one is stored in a variable and then passed to all vshTableRowAppend() calls, the others are passed as a function call. Switch the latter to variables too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
ab7f877f27
commit
cf0e0715e0
@ -1889,6 +1889,9 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
ignore_value(virStrcpyStatic(id_buf, "-"));
|
ignore_value(virStrcpyStatic(id_buf, "-"));
|
||||||
|
|
||||||
if (optTable) {
|
if (optTable) {
|
||||||
|
const char *domName = virDomainGetName(dom);
|
||||||
|
const char *stateStr = NULL;
|
||||||
|
|
||||||
state = virshDomainState(ctl, dom, NULL);
|
state = virshDomainState(ctl, dom, NULL);
|
||||||
|
|
||||||
/* Domain could've been removed in the meantime */
|
/* Domain could've been removed in the meantime */
|
||||||
@ -1896,8 +1899,11 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (managed && state == VIR_DOMAIN_SHUTOFF &&
|
if (managed && state == VIR_DOMAIN_SHUTOFF &&
|
||||||
virDomainHasManagedSaveImage(dom, 0) > 0)
|
virDomainHasManagedSaveImage(dom, 0) > 0) {
|
||||||
state = -2;
|
stateStr = _("saved");
|
||||||
|
} else {
|
||||||
|
stateStr = virshDomainStateToString(state);
|
||||||
|
}
|
||||||
|
|
||||||
if (optTitle && !optUUID) {
|
if (optTitle && !optUUID) {
|
||||||
g_autofree char *title = NULL;
|
g_autofree char *title = NULL;
|
||||||
@ -1905,9 +1911,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
|
if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (vshTableRowAppend(table, id_buf,
|
if (vshTableRowAppend(table, id_buf,
|
||||||
virDomainGetName(dom),
|
domName, stateStr,
|
||||||
state == -2 ? _("saved")
|
|
||||||
: virshDomainStateToString(state),
|
|
||||||
title, NULL) < 0)
|
title, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (optUUID && !optTitle) {
|
} else if (optUUID && !optTitle) {
|
||||||
@ -1916,9 +1920,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (vshTableRowAppend(table, id_buf,
|
if (vshTableRowAppend(table, id_buf,
|
||||||
virDomainGetName(dom),
|
domName, stateStr,
|
||||||
state == -2 ? _("saved")
|
|
||||||
: virshDomainStateToString(state),
|
|
||||||
uuid, NULL) < 0)
|
uuid, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (optUUID && optTitle) {
|
} else if (optUUID && optTitle) {
|
||||||
@ -1931,16 +1933,12 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (vshTableRowAppend(table, id_buf,
|
if (vshTableRowAppend(table, id_buf,
|
||||||
virDomainGetName(dom),
|
domName, stateStr,
|
||||||
state == -2 ? _("saved")
|
|
||||||
: virshDomainStateToString(state),
|
|
||||||
title, uuid, NULL) < 0)
|
title, uuid, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
if (vshTableRowAppend(table, id_buf,
|
if (vshTableRowAppend(table, id_buf,
|
||||||
virDomainGetName(dom),
|
domName, stateStr,
|
||||||
state == -2 ? _("saved")
|
|
||||||
: virshDomainStateToString(state),
|
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user