提交 146ba114 编写于 作者: E Eric Blake

syntax: prefer space after semicolon in for loop

I noticed several unusual spacings in for loops, and decided to
fix them up.  See the next commit for the syntax check that found
all of these.

* examples/domsuspend/suspend.c (main): Fix spacing.
* python/libvirt-override.c: Likewise.
* src/conf/interface_conf.c: Likewise.
* src/security/virt-aa-helper.c: Likewise.
* src/util/virconf.c: Likewise.
* src/util/virhook.c: Likewise.
* src/util/virlog.c: Likewise.
* src/util/virsocketaddr.c: Likewise.
* src/util/virsysinfo.c: Likewise.
* src/util/viruuid.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* tools/virsh-domain-monitor.c (vshDomainStateToString): Drop
default case, to let compiler check us.
* tools/virsh-domain.c (vshDomainVcpuStateToString): Likewise.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 2da3bc64
......@@ -113,7 +113,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Failed to list the domains\n");
goto error;
}
for (j = 0;j < i;j++) {
for (j = 0; j < i; j++) {
if (ids[j] != 0) {
id = ids[j];
break;
......
......@@ -2176,7 +2176,7 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (ids) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_intWrap(ids[i]));
}
VIR_FREE(ids);
......@@ -2266,7 +2266,7 @@ libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -2745,7 +2745,7 @@ libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -2790,7 +2790,7 @@ libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -2997,7 +2997,7 @@ libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg
return VIR_PY_NONE;
}
py_retval = PyList_New(c_retval);
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i,
libvirt_longlongWrap((long long) freeMems[i]));
}
......@@ -3165,7 +3165,7 @@ libvirt_virConnectListStoragePools(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (py_retval == NULL) {
if (names) {
for (i = 0;i < c_retval;i++)
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
}
......@@ -3173,7 +3173,7 @@ libvirt_virConnectListStoragePools(PyObject *self ATTRIBUTE_UNUSED,
}
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -3218,7 +3218,7 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (py_retval == NULL) {
if (names) {
for (i = 0;i < c_retval;i++)
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
}
......@@ -3226,7 +3226,7 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
}
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -3317,7 +3317,7 @@ libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (py_retval == NULL) {
if (names) {
for (i = 0;i < c_retval;i++)
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
}
......@@ -3325,7 +3325,7 @@ libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
}
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -3578,7 +3578,7 @@ libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -3668,7 +3668,7 @@ libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -3787,7 +3787,7 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (uuids) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
VIR_FREE(uuids[i]);
}
......@@ -4006,7 +4006,7 @@ libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (uuids) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
VIR_FREE(uuids[i]);
}
......@@ -4097,7 +4097,7 @@ libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (py_retval == NULL) {
if (names) {
for (i = 0;i < c_retval;i++)
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
}
......@@ -4105,7 +4105,7 @@ libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
}
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......@@ -4151,7 +4151,7 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (py_retval == NULL) {
if (names) {
for (i = 0;i < c_retval;i++)
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
}
......@@ -4159,7 +4159,7 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED,
}
if (names) {
for (i = 0;i < c_retval;i++) {
for (i = 0; i < c_retval; i++) {
PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
VIR_FREE(names[i]);
}
......
/*
* interface_conf.c: interfaces XML handling
*
* Copyright (C) 2006-2010 Red Hat, Inc.
* Copyright (C) 2006-2010, 2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -80,7 +80,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
switch (def->type) {
case VIR_INTERFACE_TYPE_BRIDGE:
VIR_FREE(def->data.bridge.delay);
for (i = 0;i < def->data.bridge.nbItf;i++) {
for (i = 0; i < def->data.bridge.nbItf; i++) {
if (def->data.bridge.itf[i] == NULL)
break; /* to cope with half parsed data on errors */
virInterfaceDefFree(def->data.bridge.itf[i]);
......@@ -89,7 +89,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
break;
case VIR_INTERFACE_TYPE_BOND:
VIR_FREE(def->data.bond.target);
for (i = 0;i < def->data.bond.nbItf;i++) {
for (i = 0; i < def->data.bond.nbItf; i++) {
if (def->data.bond.itf[i] == NULL)
break; /* to cope with half parsed data on errors */
virInterfaceDefFree(def->data.bond.itf[i]);
......@@ -504,7 +504,7 @@ virInterfaceDefParseBridge(virInterfaceDefPtr def,
}
def->data.bridge.nbItf = nbItf;
for (i = 0; i < nbItf;i++) {
for (i = 0; i < nbItf; i++) {
ctxt->node = interfaces[i];
itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BRIDGE);
if (itf == NULL) {
......@@ -551,7 +551,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
}
def->data.bond.nbItf = nbItf;
for (i = 0; i < nbItf;i++) {
for (i = 0; i < nbItf; i++) {
ctxt->node = interfaces[i];
itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BOND);
if (itf == NULL) {
......@@ -886,7 +886,7 @@ virInterfaceBridgeDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " delay='%s'", def->data.bridge.delay);
virBufferAddLit(buf, ">\n");
for (i = 0;i < def->data.bridge.nbItf;i++) {
for (i = 0; i < def->data.bridge.nbItf; i++) {
if (virInterfaceDefDevFormat(buf,
def->data.bridge.itf[i], level+2) < 0)
ret = -1;
......@@ -948,7 +948,7 @@ virInterfaceBondDefFormat(virBufferPtr buf,
virBufferAddLit(buf, " validate='all'");
virBufferAddLit(buf, "/>\n");
}
for (i = 0;i < def->data.bond.nbItf;i++) {
for (i = 0; i < def->data.bond.nbItf; i++) {
if (virInterfaceDefDevFormat(buf, def->data.bond.itf[i], level+2) < 0)
ret = -1;
}
......
......@@ -71,7 +71,7 @@ typedef struct {
char *files; /* list of files */
virDomainDefPtr def; /* VM definition */
virCapsPtr caps; /* VM capabilities */
virDomainXMLOptionPtr xmlopt;/* XML parser data */
virDomainXMLOptionPtr xmlopt; /* XML parser data */
char *hvm; /* type of hypervisor (eg hvm, xen) */
virArch arch; /* machine architecture */
char *newfile; /* newly added file */
......
/*
* virconf.c: parser for a subset of the Python encoded Xen configuration files
*
* Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -67,7 +67,7 @@ struct _virConfParserCtxt {
#define SKIP_BLANKS_AND_EOL \
do { while ((ctxt->cur < ctxt->end) && (c_isblank(CUR) || IS_EOL(CUR))) { \
if (CUR == '\n') ctxt->line++; \
ctxt->cur++;}} while (0)
ctxt->cur++; } } while (0)
#define SKIP_BLANKS \
do { while ((ctxt->cur < ctxt->end) && (c_isblank(CUR))) \
ctxt->cur++; } while (0)
......
......@@ -142,7 +142,7 @@ virHookInitialize(void) {
int i, res, ret = 0;
virHooksFound = 0;
for (i = 0;i < VIR_HOOK_DRIVER_LAST;i++) {
for (i = 0; i < VIR_HOOK_DRIVER_LAST; i++) {
res = virHookCheck(i, virHookDriverTypeToString(i));
if (res < 0)
return -1;
......
......@@ -371,7 +371,7 @@ virLogDumpAllFD(const char *msg, int len)
if (len <= 0)
len = strlen(msg);
for (i = 0; i < virLogNbOutputs;i++) {
for (i = 0; i < virLogNbOutputs; i++) {
if (virLogOutputs[i].f == virLogOutputToFd) {
int fd = (intptr_t) virLogOutputs[i].data;
......@@ -514,7 +514,7 @@ virLogResetFilters(void)
{
int i;
for (i = 0; i < virLogNbFilters;i++)
for (i = 0; i < virLogNbFilters; i++)
VIR_FREE(virLogFilters[i].match);
VIR_FREE(virLogFilters);
virLogNbFilters = 0;
......@@ -550,7 +550,7 @@ virLogDefineFilter(const char *match,
return -1;
virLogLock();
for (i = 0;i < virLogNbFilters;i++) {
for (i = 0; i < virLogNbFilters; i++) {
if (STREQ(virLogFilters[i].match, match)) {
virLogFilters[i].priority = priority;
goto cleanup;
......@@ -597,7 +597,7 @@ virLogFiltersCheck(const char *input,
int i;
virLogLock();
for (i = 0;i < virLogNbFilters;i++) {
for (i = 0; i < virLogNbFilters; i++) {
if (strstr(input, virLogFilters[i].match)) {
ret = virLogFilters[i].priority;
*flags = virLogFilters[i].flags;
......@@ -621,7 +621,7 @@ virLogResetOutputs(void)
{
int i;
for (i = 0;i < virLogNbOutputs;i++) {
for (i = 0; i < virLogNbOutputs; i++) {
if (virLogOutputs[i].c != NULL)
virLogOutputs[i].c(virLogOutputs[i].data);
VIR_FREE(virLogOutputs[i].name);
......
......@@ -49,7 +49,7 @@ static int virSocketAddrGetIPv4Addr(virSocketAddrPtr addr, virSocketAddrIPv4Ptr
val = ntohl(addr->data.inet4.sin_addr.s_addr);
for (i = 0;i < 4;i++) {
for (i = 0; i < 4; i++) {
(*tab)[3 - i] = val & 0xFF;
val >>= 8;
}
......@@ -63,7 +63,7 @@ static int virSocketAddrGetIPv6Addr(virSocketAddrPtr addr, virSocketAddrIPv6Ptr
if ((addr == NULL) || (tab == NULL) || (addr->data.stor.ss_family != AF_INET6))
return -1;
for (i = 0;i < 8;i++) {
for (i = 0; i < 8; i++) {
(*tab)[i] = ((addr->data.inet6.sin6_addr.s6_addr[2 * i] << 8) |
addr->data.inet6.sin6_addr.s6_addr[2 * i + 1]);
}
......@@ -530,7 +530,7 @@ int virSocketAddrCheckNetmask(virSocketAddrPtr addr1, virSocketAddrPtr addr2,
(virSocketAddrGetIPv4Addr(netmask, &tm) < 0))
return -1;
for (i = 0;i < 4;i++) {
for (i = 0; i < 4; i++) {
if ((t1[i] & tm[i]) != (t2[i] & tm[i]))
return 0;
}
......@@ -543,7 +543,7 @@ int virSocketAddrCheckNetmask(virSocketAddrPtr addr1, virSocketAddrPtr addr2,
(virSocketAddrGetIPv6Addr(netmask, &tm) < 0))
return -1;
for (i = 0;i < 8;i++) {
for (i = 0; i < 8; i++) {
if ((t1[i] & tm[i]) != (t2[i] & tm[i]))
return 0;
}
......@@ -581,7 +581,7 @@ int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end) {
(virSocketAddrGetIPv4Addr(end, &t2) < 0))
return -1;
for (i = 0;i < 2;i++) {
for (i = 0; i < 2; i++) {
if (t1[i] != t2[i])
return -1;
}
......@@ -596,7 +596,7 @@ int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end) {
(virSocketAddrGetIPv6Addr(end, &t2) < 0))
return -1;
for (i = 0;i < 7;i++) {
for (i = 0; i < 7; i++) {
if (t1[i] != t2[i])
return -1;
}
......
......@@ -91,7 +91,7 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
VIR_FREE(def->system_sku);
VIR_FREE(def->system_family);
for (i = 0;i < def->nprocessor;i++) {
for (i = 0; i < def->nprocessor; i++) {
VIR_FREE(def->processor[i].processor_socket_destination);
VIR_FREE(def->processor[i].processor_type);
VIR_FREE(def->processor[i].processor_family);
......@@ -105,7 +105,7 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
VIR_FREE(def->processor[i].processor_part_number);
}
VIR_FREE(def->processor);
for (i = 0;i < def->nmemory;i++) {
for (i = 0; i < def->nmemory; i++) {
VIR_FREE(def->memory[i].memory_size);
VIR_FREE(def->memory[i].memory_form_factor);
VIR_FREE(def->memory[i].memory_locator);
......
/*
* viruuid.h: helper APIs for dealing with UUIDs
*
* Copyright (C) 2007-2012 Red Hat, Inc.
* Copyright (C) 2007-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -160,7 +160,7 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
while (c_isspace(*cur))
cur++;
for (i = 0;i < VIR_UUID_BUFLEN;) {
for (i = 0; i < VIR_UUID_BUFLEN;) {
uuid[i] = 0;
if (*cur == 0)
goto error;
......
......@@ -2938,7 +2938,7 @@ sharedFoldersCleanup:
}
/* Now get the details about the network cards here */
for (i = 0;(netAdpIncCnt < def->nnets) && (i < netAdpCnt); i++) {
for (i = 0; netAdpIncCnt < def->nnets && i < netAdpCnt; i++) {
INetworkAdapter *adapter = NULL;
machine->vtbl->GetNetworkAdapter(machine, i, &adapter);
......@@ -3216,7 +3216,9 @@ sharedFoldersCleanup:
}
/* Now get the details about the serial ports here */
for (i = 0;(serialPortIncCount < def->nserials) && (i < serialPortCount); i++) {
for (i = 0;
serialPortIncCount < def->nserials && i < serialPortCount;
i++) {
ISerialPort *serialPort = NULL;
machine->vtbl->GetSerialPort(machine, i, &serialPort);
......@@ -3300,7 +3302,10 @@ sharedFoldersCleanup:
}
/* Now get the details about the parallel ports here */
for (i = 0;(parallelPortIncCount < def->nparallels) && (i < parallelPortCount); i++) {
for (i = 0;
parallelPortIncCount < def->nparallels &&
i < parallelPortCount;
i++) {
IParallelPort *parallelPort = NULL;
machine->vtbl->GetParallelPort(machine, i, &parallelPort);
......
......@@ -2873,7 +2873,8 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
memset(&op_sys, 0, sizeof(op_sys));
op_sys.cmd = XEN_V2_OP_GETAVAILHEAP;
for (i = startCell, j = 0;(i < priv->nbNodeCells) && (j < maxCells);i++,j++) {
for (i = startCell, j = 0;
i < priv->nbNodeCells && j < maxCells; i++, j++) {
if (hv_versions.sys_interface >= 5)
op_sys.u.availheap5.node = i;
else
......
/*
* virsh-domain-monitor.c: Commands to monitor domain status
*
* Copyright (C) 2005, 2007-2012 Red Hat, Inc.
* Copyright (C) 2005, 2007-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -156,8 +156,8 @@ vshDomainStateToString(int state)
case VIR_DOMAIN_PMSUSPENDED:
return N_("pmsuspended");
case VIR_DOMAIN_NOSTATE:
default:
;/*FALLTHROUGH*/
case VIR_DOMAIN_LAST:
break;
}
return N_("no state"); /* = dom0 state */
}
......
......@@ -114,15 +114,15 @@ vshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
static const char *
vshDomainVcpuStateToString(int state)
{
switch (state) {
switch ((virVcpuState) state) {
case VIR_VCPU_OFFLINE:
return N_("offline");
case VIR_VCPU_BLOCKED:
return N_("idle");
case VIR_VCPU_RUNNING:
return N_("running");
default:
;/*FALLTHROUGH*/
case VIR_VCPU_LAST:
break;
}
return N_("no state");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册