mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: cmdStart: Rewrite ternary operator use to standard if conditions
Rewrite the invocation of the virDomainCreate(WithFiles/Flags) APIs based on the arguments into if-else instead of (nested) ternary operators. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
1cd95f858a
commit
38b600166f
@ -4104,10 +4104,15 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
/* We can emulate force boot, even for older servers that reject it. */
|
||||
if (flags & VIR_DOMAIN_START_FORCE_BOOT) {
|
||||
if ((nfds ?
|
||||
virDomainCreateWithFiles(dom, nfds, fds, flags) :
|
||||
virDomainCreateWithFlags(dom, flags)) == 0)
|
||||
if (nfds > 0) {
|
||||
rc = virDomainCreateWithFiles(dom, nfds, fds, flags);
|
||||
} else {
|
||||
rc = virDomainCreateWithFlags(dom, flags);
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
goto started;
|
||||
|
||||
if (last_error->code != VIR_ERR_NO_SUPPORT &&
|
||||
last_error->code != VIR_ERR_INVALID_ARG) {
|
||||
vshReportError(ctl);
|
||||
@ -4128,9 +4133,15 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
/* Prefer older API unless we have to pass a flag. */
|
||||
if ((nfds ? virDomainCreateWithFiles(dom, nfds, fds, flags) :
|
||||
(flags ? virDomainCreateWithFlags(dom, flags)
|
||||
: virDomainCreate(dom))) < 0) {
|
||||
if (nfds > 0) {
|
||||
rc = virDomainCreateWithFiles(dom, nfds, fds, flags);
|
||||
} else if (flags != 0) {
|
||||
rc = virDomainCreateWithFlags(dom, flags);
|
||||
} else {
|
||||
rc = virDomainCreate(dom);
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
vshError(ctl, _("Failed to start domain '%s'"), virDomainGetName(dom));
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user