mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 05:45:46 +00:00
virsh: Simplify control flow for 'desc' command
Just like the commit 8941c800
, It does the similar thing.
Signed-off-by: Lin Ma <lma@suse.com>
This commit is contained in:
parent
2273e408d9
commit
b9e3c8c5c0
@ -8330,7 +8330,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
char *tmpstr;
|
char *tmpstr;
|
||||||
const vshCmdOpt *opt = NULL;
|
const vshCmdOpt *opt = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
bool pad = false;
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
|
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
|
||||||
|
|
||||||
@ -8348,18 +8347,16 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if ((state = virshDomainState(ctl, dom, NULL)) < 0)
|
if ((state = virshDomainState(ctl, dom, NULL)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
|
|
||||||
if (pad)
|
|
||||||
virBufferAddChar(&buf, ' ');
|
|
||||||
pad = true;
|
|
||||||
virBufferAdd(&buf, opt->data, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title)
|
if (title)
|
||||||
type = VIR_DOMAIN_METADATA_TITLE;
|
type = VIR_DOMAIN_METADATA_TITLE;
|
||||||
else
|
else
|
||||||
type = VIR_DOMAIN_METADATA_DESCRIPTION;
|
type = VIR_DOMAIN_METADATA_DESCRIPTION;
|
||||||
|
|
||||||
|
while ((opt = vshCommandOptArgv(ctl, cmd, opt)))
|
||||||
|
virBufferAsprintf(&buf, "%s ", opt->data);
|
||||||
|
|
||||||
|
virBufferTrim(&buf, " ", -1);
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
vshError(ctl, "%s", _("Failed to collect new description/title"));
|
vshError(ctl, "%s", _("Failed to collect new description/title"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user