Remove unnecessary curly brackets in tools/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-11-13 15:20:51 +01:00
parent 4fab120923
commit 91cc3d9570
8 changed files with 28 additions and 56 deletions

View File

@ -224,9 +224,8 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
con->terminalToStream.offset, con->terminalToStream.offset,
avail); avail);
if (got < 0) { if (got < 0) {
if (errno != EAGAIN) { if (errno != EAGAIN)
virConsoleShutdown(con); virConsoleShutdown(con);
}
return; return;
} }
if (got == 0) { if (got == 0) {
@ -268,9 +267,8 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
con->streamToTerminal.data, con->streamToTerminal.data,
con->streamToTerminal.offset); con->streamToTerminal.offset);
if (done < 0) { if (done < 0) {
if (errno != EAGAIN) { if (errno != EAGAIN)
virConsoleShutdown(con); virConsoleShutdown(con);
}
return; return;
} }
memmove(con->streamToTerminal.data, memmove(con->streamToTerminal.data,

View File

@ -161,10 +161,9 @@ vshNodeGetCPUCount(virConnectPtr conn)
if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) { if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) {
/* fall back to nodeinfo */ /* fall back to nodeinfo */
vshResetLibvirtError(); vshResetLibvirtError();
if (virNodeGetInfo(conn, &nodeinfo) == 0) { if (virNodeGetInfo(conn, &nodeinfo) == 0)
ret = VIR_NODEINFO_MAXCPUS(nodeinfo); ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
} }
}
return ret; return ret;
} }
@ -3446,9 +3445,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA; flags |= VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA;
snapshots_safe = true; snapshots_safe = true;
} }
if (nvram) { if (nvram)
flags |= VIR_DOMAIN_UNDEFINE_NVRAM; flags |= VIR_DOMAIN_UNDEFINE_NVRAM;
}
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -3498,9 +3496,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
flags &= ~VIR_DOMAIN_UNDEFINE_MANAGED_SAVE; flags &= ~VIR_DOMAIN_UNDEFINE_MANAGED_SAVE;
managed_save_safe = true; managed_save_safe = true;
} }
if (has_snapshots == 0) { if (has_snapshots == 0)
snapshots_safe = true; snapshots_safe = true;
}
if (has_snapshots_metadata == 0) { if (has_snapshots_metadata == 0) {
flags &= ~VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA; flags &= ~VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA;
snapshots_safe = true; snapshots_safe = true;
@ -6183,9 +6180,8 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
int cpu, lastcpu; int cpu, lastcpu;
bool bit, lastbit, isInvert; bool bit, lastbit, isInvert;
if (!cpumaps || cpumaplen <= 0 || maxcpu <= 0 || vcpuindex < 0) { if (!cpumaps || cpumaplen <= 0 || maxcpu <= 0 || vcpuindex < 0)
return false; return false;
}
bit = lastbit = isInvert = false; bit = lastbit = isInvert = false;
lastcpu = -1; lastcpu = -1;
@ -6205,9 +6201,8 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
vshPrint(ctl, "-%d", cpu - 1); vshPrint(ctl, "-%d", cpu - 1);
lastbit = bit; lastbit = bit;
} }
if (bit && !isInvert) { if (bit && !isInvert)
vshPrint(ctl, "-%d", maxcpu - 1); vshPrint(ctl, "-%d", maxcpu - 1);
}
return true; return true;
} }
@ -6364,9 +6359,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
} }
if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) { if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
goto cleanup; goto cleanup;
}
cpumaplen = VIR_CPU_MAPLEN(maxcpu); cpumaplen = VIR_CPU_MAPLEN(maxcpu);
@ -7934,14 +7928,12 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
kibibytes = VIR_DIV_UP(bytes, 1024); kibibytes = VIR_DIV_UP(bytes, 1024);
if (flags == -1) { if (flags == -1) {
if (virDomainSetMemory(dom, kibibytes) != 0) { if (virDomainSetMemory(dom, kibibytes) != 0)
ret = false; ret = false;
}
} else { } else {
if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) { if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0)
ret = false; ret = false;
} }
}
virDomainFree(dom); virDomainFree(dom);
return ret; return ret;
@ -9494,9 +9486,8 @@ doMigrate(void *opaque)
if (vshCommandOptBool(cmd, "rdma-pin-all")) if (vshCommandOptBool(cmd, "rdma-pin-all"))
flags |= VIR_MIGRATE_RDMA_PIN_ALL; flags |= VIR_MIGRATE_RDMA_PIN_ALL;
if (vshCommandOptBool(cmd, "offline")) { if (vshCommandOptBool(cmd, "offline"))
flags |= VIR_MIGRATE_OFFLINE; flags |= VIR_MIGRATE_OFFLINE;
}
if (vshCommandOptBool(cmd, "abort-on-error")) if (vshCommandOptBool(cmd, "abort-on-error"))
flags |= VIR_MIGRATE_ABORT_ON_ERROR; flags |= VIR_MIGRATE_ABORT_ON_ERROR;

View File

@ -85,9 +85,8 @@ do {
goto edit_cleanup; goto edit_cleanup;
/* Compare original XML with edited. Has it changed at all? */ /* Compare original XML with edited. Has it changed at all? */
if (STREQ(doc, doc_edited)) { if (STREQ(doc, doc_edited))
EDIT_NOT_CHANGED; EDIT_NOT_CHANGED;
}
redefine: redefine:
msg = NULL; msg = NULL;
@ -109,9 +108,8 @@ do {
} }
/* Everything checks out, so redefine the object. */ /* Everything checks out, so redefine the object. */
if (!msg && !(EDIT_DEFINE)) { if (!msg && !(EDIT_DEFINE))
msg = _("Failed."); msg = _("Failed.");
}
if (msg) { if (msg) {
int c = vshAskReedit(ctl, msg); int c = vshAskReedit(ctl, msg);

View File

@ -376,9 +376,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
vshPrint(ctl, _("Node %d:\n"), cell); vshPrint(ctl, _("Node %d:\n"), cell);
for (j = 0; j < npages; j++) { for (j = 0; j < npages; j++)
vshPrint(ctl, "%uKiB: %lld\n", pagesize[j], counts[j]); vshPrint(ctl, "%uKiB: %lld\n", pagesize[j], counts[j]);
}
vshPrint(ctl, "%c", '\n'); vshPrint(ctl, "%c", '\n');
} }

View File

@ -470,13 +470,11 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
if (vshCommandOptBool(cmd, "no-overwrite")) { if (vshCommandOptBool(cmd, "no-overwrite"))
flags |= VIR_STORAGE_POOL_BUILD_NO_OVERWRITE; flags |= VIR_STORAGE_POOL_BUILD_NO_OVERWRITE;
}
if (vshCommandOptBool(cmd, "overwrite")) { if (vshCommandOptBool(cmd, "overwrite"))
flags |= VIR_STORAGE_POOL_BUILD_OVERWRITE; flags |= VIR_STORAGE_POOL_BUILD_OVERWRITE;
}
if (virStoragePoolBuild(pool, flags) == 0) { if (virStoragePoolBuild(pool, flags) == 0) {
vshPrint(ctl, _("Pool %s built\n"), name); vshPrint(ctl, _("Pool %s built\n"), name);

View File

@ -687,9 +687,8 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
return false; return false;
}
if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
goto cleanup; goto cleanup;
@ -885,9 +884,8 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
return false; return false;
}
if (virStorageVolDelete(vol, 0) == 0) { if (virStorageVolDelete(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s deleted\n"), name); vshPrint(ctl, _("Vol %s deleted\n"), name);
@ -945,9 +943,8 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO; int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
int funcRet; int funcRet;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
return false; return false;
}
if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0) if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0)
goto out; goto out;
@ -1741,9 +1738,8 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
virStorageVolPtr vol; virStorageVolPtr vol;
char * StorageVolPath; char * StorageVolPath;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false; return false;
}
if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) { if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) {
virStorageVolFree(vol); virStorageVolFree(vol);

View File

@ -499,9 +499,8 @@ vshPrintRaw(vshControl *ctl, ...)
char *key; char *key;
va_start(ap, ctl); va_start(ap, ctl);
while ((key = va_arg(ap, char *)) != NULL) { while ((key = va_arg(ap, char *)) != NULL)
vshPrint(ctl, "%s\r\n", key); vshPrint(ctl, "%s\r\n", key);
}
va_end(ap); va_end(ap);
} }
@ -874,9 +873,8 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (vshCommandOptString(cmd, "dir", &dir) <= 0) { if (vshCommandOptString(cmd, "dir", &dir) <= 0)
dir = dir_malloced = virGetUserDirectory(); dir = dir_malloced = virGetUserDirectory();
}
if (!dir) if (!dir)
dir = "/"; dir = "/";
@ -1139,9 +1137,8 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
const vshCmdOptDef *ret = NULL; const vshCmdOptDef *ret = NULL;
char *alias = NULL; char *alias = NULL;
if (STREQ(name, helpopt.name)) { if (STREQ(name, helpopt.name))
return &helpopt; return &helpopt;
}
for (i = 0; cmd->opts && cmd->opts[i].name; i++) { for (i = 0; cmd->opts && cmd->opts[i].name; i++) {
const vshCmdOptDef *opt = &cmd->opts[i]; const vshCmdOptDef *opt = &cmd->opts[i];
@ -1651,9 +1648,8 @@ vshCommandOptString(const vshCmd *cmd, const char *name, const char **value)
if (ret <= 0) if (ret <= 0)
return ret; return ret;
if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) { if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
return -1; return -1;
}
*value = arg->data; *value = arg->data;
return 1; return 1;
} }
@ -1848,9 +1844,8 @@ vshCommandOptArgv(const vshCmd *cmd, const vshCmdOpt *opt)
opt = opt ? opt->next : cmd->opts; opt = opt ? opt->next : cmd->opts;
while (opt) { while (opt) {
if (opt->def->type == VSH_OT_ARGV) { if (opt->def->type == VSH_OT_ARGV)
return opt; return opt;
}
opt = opt->next; opt = opt->next;
} }
return NULL; return NULL;
@ -3712,9 +3707,8 @@ main(int argc, char **argv)
else else
progname++; progname++;
if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"))) { if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
ctl->name = vshStrdup(ctl, defaultConn); ctl->name = vshStrdup(ctl, defaultConn);
}
vshInitDebug(ctl); vshInitDebug(ctl);

View File

@ -249,9 +249,8 @@ find_payload_dissector(guint32 proc, guint32 type,
first = pds[0].proc; first = pds[0].proc;
last = pds[length-1].proc; last = pds[length-1].proc;
if (proc < first || proc > last) { if (proc < first || proc > last)
return NULL; return NULL;
}
pd = &pds[proc-first]; pd = &pds[proc-first];
/* There is no guarantee to proc numbers has no gap */ /* There is no guarantee to proc numbers has no gap */
@ -329,10 +328,9 @@ dissect_libvirt_payload_xdr_data(tvbuff_t *tvb, proto_tree *tree, gint payload_l
xdr_destroy(&xdrs); xdr_destroy(&xdrs);
g_free(payload_data); g_free(payload_data);
if (nfds != 0) { if (nfds != 0)
dissect_libvirt_fds(tvb, start + payload_length, nfds); dissect_libvirt_fds(tvb, start + payload_length, nfds);
} }
}
static void static void
dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree, dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,