tools: remove unneeded cleanup labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2019-10-21 15:19:09 -03:00 committed by Ján Tomko
parent c0666eb7c8
commit 10d6290f1c
3 changed files with 19 additions and 38 deletions

View File

@ -74,21 +74,17 @@ virshNetworkEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
unsigned int flags) unsigned int flags)
{ {
size_t i = 0; size_t i = 0;
char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL; VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
if (VIR_ALLOC_N(tmp, VIR_NETWORK_EVENT_ID_LAST + 1) < 0) 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++) for (i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++)
tmp[i] = g_strdup(virshNetworkEventCallbacks[i].name); tmp[i] = g_strdup(virshNetworkEventCallbacks[i].name);
ret = g_steal_pointer(&tmp); return g_steal_pointer(&tmp);
cleanup:
return ret;
} }

View File

@ -2571,7 +2571,6 @@ virshBlockJobInfo(vshControl *ctl,
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
unsigned long long speed; unsigned long long speed;
unsigned int flags = 0; unsigned int flags = 0;
bool ret = false;
int rc = -1; int rc = -1;
/* If bytes were requested, or if raw mode is not forcing a MiB/s /* If bytes were requested, or if raw mode is not forcing a MiB/s
@ -2593,7 +2592,7 @@ virshBlockJobInfo(vshControl *ctl,
} }
G_GNUC_FALLTHROUGH; G_GNUC_FALLTHROUGH;
default: default:
goto cleanup; return false;
} }
} }
speed = info.bandwidth; speed = info.bandwidth;
@ -2602,7 +2601,7 @@ virshBlockJobInfo(vshControl *ctl,
if (rc < 0) { if (rc < 0) {
flags &= ~VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES; flags &= ~VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES;
if ((rc = virDomainGetBlockJobInfo(dom, path, &info, flags)) < 0) if ((rc = virDomainGetBlockJobInfo(dom, path, &info, flags)) < 0)
goto cleanup; return false;
speed = info.bandwidth; speed = info.bandwidth;
/* Scale to bytes/s unless in raw mode */ /* Scale to bytes/s unless in raw mode */
if (!raw) { if (!raw) {
@ -2610,7 +2609,7 @@ virshBlockJobInfo(vshControl *ctl,
if (speed >> 20 != info.bandwidth) { if (speed >> 20 != info.bandwidth) {
vshError(ctl, _("overflow in converting %ld MiB/s to bytes\n"), vshError(ctl, _("overflow in converting %ld MiB/s to bytes\n"),
info.bandwidth); info.bandwidth);
goto cleanup; return false;
} }
} }
} }
@ -2618,8 +2617,7 @@ virshBlockJobInfo(vshControl *ctl,
if (rc == 0) { if (rc == 0) {
if (!raw) if (!raw)
vshPrintExtra(ctl, _("No current block job for %s"), path); vshPrintExtra(ctl, _("No current block job for %s"), path);
ret = true; return true;
goto cleanup;
} }
if (raw) { if (raw) {
@ -2638,10 +2636,7 @@ virshBlockJobInfo(vshControl *ctl,
vshPrint(ctl, "\n"); vshPrint(ctl, "\n");
} }
ret = true; return true;
cleanup:
return ret;
} }
@ -2982,34 +2977,31 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
const char *name, const char *name,
unsigned int flags) unsigned int flags)
{ {
bool ret = false;
int state; int state;
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
if ((state = virshDomainState(ctl, dom, NULL)) < 0) { if ((state = virshDomainState(ctl, dom, NULL)) < 0) {
vshError(ctl, "%s", _("Unable to get domain status")); vshError(ctl, "%s", _("Unable to get domain status"));
goto cleanup; return false;
} }
if (state == VIR_DOMAIN_SHUTOFF) { if (state == VIR_DOMAIN_SHUTOFF) {
vshError(ctl, "%s", _("The domain is not running")); vshError(ctl, "%s", _("The domain is not running"));
goto cleanup; return false;
} }
if (!isatty(STDIN_FILENO)) { if (!isatty(STDIN_FILENO)) {
vshError(ctl, "%s", _("Cannot run interactive console without a controlling TTY")); 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, _("Connected to domain %s\n"), virDomainGetName(dom));
vshPrintExtra(ctl, _("Escape character is %s\n"), priv->escapeChar); vshPrintExtra(ctl, _("Escape character is %s\n"), priv->escapeChar);
fflush(stdout); fflush(stdout);
if (virshRunConsole(ctl, dom, name, flags) == 0) if (virshRunConsole(ctl, dom, name, flags) == 0)
ret = true; return true;
cleanup: return false;
return ret;
} }
static bool static bool
@ -5044,7 +5036,7 @@ cmdSchedInfoUpdateOne(vshControl *ctl,
field, param->type, field, param->type,
value) < 0) { value) < 0) {
vshSaveLibvirtError(); vshSaveLibvirtError();
goto cleanup; return -1;
} }
ret = 0; ret = 0;
break; break;
@ -5053,7 +5045,6 @@ cmdSchedInfoUpdateOne(vshControl *ctl,
if (ret < 0) if (ret < 0)
vshError(ctl, _("invalid scheduler option: %s"), field); vshError(ctl, _("invalid scheduler option: %s"), field);
cleanup:
return ret; return ret;
} }
@ -9708,26 +9699,22 @@ static bool
cmdQemuAttach(vshControl *ctl, const vshCmd *cmd) cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
{ {
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
bool ret = false;
unsigned int flags = 0; unsigned int flags = 0;
unsigned int pid_value; /* API uses unsigned int, not pid_t */ unsigned int pid_value; /* API uses unsigned int, not pid_t */
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <= 0) if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <= 0)
goto cleanup; return false;
if (!(dom = virDomainQemuAttach(priv->conn, pid_value, flags))) { if (!(dom = virDomainQemuAttach(priv->conn, pid_value, flags))) {
vshError(ctl, _("Failed to attach to pid %u"), pid_value); vshError(ctl, _("Failed to attach to pid %u"), pid_value);
goto cleanup; return false;
} }
vshPrintExtra(ctl, _("Domain %s attached to pid %u\n"), vshPrintExtra(ctl, _("Domain %s attached to pid %u\n"),
virDomainGetName(dom), pid_value); virDomainGetName(dom), pid_value);
virshDomainFree(dom); virshDomainFree(dom);
ret = true; return true;
cleanup:
return ret;
} }
/* /*

View File

@ -2514,7 +2514,6 @@ vshTreePrintInternal(vshControl *ctl,
{ {
size_t i; size_t i;
int nextlastdev = -1; int nextlastdev = -1;
int ret = -1;
const char *dev = (lookup)(devid, false, opaque); const char *dev = (lookup)(devid, false, opaque);
/* Print this device, with indent if not at root */ /* Print this device, with indent if not at root */
@ -2548,7 +2547,7 @@ vshTreePrintInternal(vshControl *ctl,
vshTreePrintInternal(ctl, lookup, opaque, vshTreePrintInternal(ctl, lookup, opaque,
num_devices, i, nextlastdev, num_devices, i, nextlastdev,
false, indent) < 0) false, indent) < 0)
goto cleanup; return -1;
} }
virBufferTrim(indent, " ", -1); virBufferTrim(indent, " ", -1);
@ -2559,9 +2558,8 @@ vshTreePrintInternal(vshControl *ctl,
if (!root) if (!root)
virBufferTrim(indent, NULL, 2); virBufferTrim(indent, NULL, 2);
ret = 0;
cleanup: return 0;
return ret;
} }
int int