Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
tools/virsh-completer-network.c | 8 ++-----
tools/virsh-domain.c | 41 +++++++++++----------------------
tools/vsh.c | 14 +++++------
3 files changed, 22 insertions(+), 41 deletions(-)
diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c
index 0097fca7cc..8f0048ed6f 100644
--- a/tools/virsh-completer-network.c
+++ b/tools/virsh-completer-network.c
@@ -74,21 +74,17 @@ virshNetworkEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
unsigned int flags)
{
size_t i = 0;
- char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
if (VIR_ALLOC_N(tmp, VIR_NETWORK_EVENT_ID_LAST + 1) < 0)
- goto cleanup;
+ return NULL;
for (i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++)
tmp[i] = g_strdup(virshNetworkEventCallbacks[i].name);
- ret = g_steal_pointer(&tmp);
-
- cleanup:
- return ret;
+ return g_steal_pointer(&tmp);
}
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2f3ac2d430..af43078205 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2583,7 +2583,6 @@ virshBlockJobInfo(vshControl *ctl,
virshControlPtr priv = ctl->privData;
unsigned long long speed;
unsigned int flags = 0;
- bool ret = false;
int rc = -1;
/* If bytes were requested, or if raw mode is not forcing a MiB/s
@@ -2605,7 +2604,7 @@ virshBlockJobInfo(vshControl *ctl,
}
G_GNUC_FALLTHROUGH;
default:
- goto cleanup;
+ return false;
}
}
speed = info.bandwidth;
@@ -2614,7 +2613,7 @@ virshBlockJobInfo(vshControl *ctl,
if (rc < 0) {
flags &= ~VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES;
if ((rc = virDomainGetBlockJobInfo(dom, path, &info, flags)) < 0)
- goto cleanup;
+ return false;
speed = info.bandwidth;
/* Scale to bytes/s unless in raw mode */
if (!raw) {
@@ -2622,7 +2621,7 @@ virshBlockJobInfo(vshControl *ctl,
if (speed >> 20 != info.bandwidth) {
vshError(ctl, _("overflow in converting %ld MiB/s to
bytes\n"),
info.bandwidth);
- goto cleanup;
+ return false;
}
}
}
@@ -2630,8 +2629,7 @@ virshBlockJobInfo(vshControl *ctl,
if (rc == 0) {
if (!raw)
vshPrintExtra(ctl, _("No current block job for %s"), path);
- ret = true;
- goto cleanup;
+ return true;
}
if (raw) {
@@ -2650,10 +2648,7 @@ virshBlockJobInfo(vshControl *ctl,
vshPrint(ctl, "\n");
}
- ret = true;
-
- cleanup:
- return ret;
+ return true;
}
@@ -2994,34 +2989,31 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
const char *name,
unsigned int flags)
{
- bool ret = false;
int state;
virshControlPtr priv = ctl->privData;
if ((state = virshDomainState(ctl, dom, NULL)) < 0) {
vshError(ctl, "%s", _("Unable to get domain status"));
- goto cleanup;
+ return false;
}
if (state == VIR_DOMAIN_SHUTOFF) {
vshError(ctl, "%s", _("The domain is not running"));
- goto cleanup;
+ return false;
}
if (!isatty(STDIN_FILENO)) {
vshError(ctl, "%s", _("Cannot run interactive console without a
controlling TTY"));
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
vshPrintExtra(ctl, _("Escape character is %s\n"), priv->escapeChar);
fflush(stdout);
if (virshRunConsole(ctl, dom, name, flags) == 0)
- ret = true;
-
- cleanup:
+ return true;
- return ret;
+ return false;
}
static bool
@@ -5056,7 +5048,7 @@ cmdSchedInfoUpdateOne(vshControl *ctl,
field, param->type,
value) < 0) {
vshSaveLibvirtError();
- goto cleanup;
+ return ret;
}
ret = 0;
break;
@@ -5065,7 +5057,6 @@ cmdSchedInfoUpdateOne(vshControl *ctl,
if (ret < 0)
vshError(ctl, _("invalid scheduler option: %s"), field);
- cleanup:
return ret;
}
@@ -9733,26 +9724,22 @@ static bool
cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- bool ret = false;
unsigned int flags = 0;
unsigned int pid_value; /* API uses unsigned int, not pid_t */
virshControlPtr priv = ctl->privData;
if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <= 0)
- goto cleanup;
+ return false;
if (!(dom = virDomainQemuAttach(priv->conn, pid_value, flags))) {
vshError(ctl, _("Failed to attach to pid %u"), pid_value);
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl, _("Domain %s attached to pid %u\n"),
virDomainGetName(dom), pid_value);
virshDomainFree(dom);
- ret = true;
-
- cleanup:
- return ret;
+ return true;
}
/*
diff --git a/tools/vsh.c b/tools/vsh.c
index 3f8b7f2186..40747edcb2 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2537,11 +2537,10 @@ vshTreePrintInternal(vshControl *ctl,
{
size_t i;
int nextlastdev = -1;
- int ret = -1;
const char *dev = (lookup)(devid, false, opaque);
if (virBufferError(indent))
- goto cleanup;
+ return -1;
/* Print this device, with indent if not at root */
vshPrint(ctl, "%s%s%s\n", virBufferCurrentContent(indent),
@@ -2552,7 +2551,7 @@ vshTreePrintInternal(vshControl *ctl,
virBufferAddChar(indent, devid == lastdev ? ' ' : '|');
virBufferAddChar(indent, ' ');
if (virBufferError(indent))
- goto cleanup;
+ return -1;
}
/* Determine the index of the last child device */
@@ -2570,7 +2569,7 @@ vshTreePrintInternal(vshControl *ctl,
/* Finally print all children */
virBufferAddLit(indent, " ");
if (virBufferError(indent))
- goto cleanup;
+ return -1;
for (i = 0; i < num_devices; i++) {
const char *parent = (lookup)(i, true, opaque);
@@ -2578,7 +2577,7 @@ vshTreePrintInternal(vshControl *ctl,
vshTreePrintInternal(ctl, lookup, opaque,
num_devices, i, nextlastdev,
false, indent) < 0)
- goto cleanup;
+ return -1;
}
virBufferTrim(indent, " ", -1);
@@ -2589,9 +2588,8 @@ vshTreePrintInternal(vshControl *ctl,
if (!root)
virBufferTrim(indent, NULL, 2);
- ret = 0;
- cleanup:
- return ret;
+
+ return 0;
}
int
--
2.21.0