mirror of https://gitee.com/openkylin/libvirt.git
use ARRAY_CARDINALITY more
* tests/nodeinfotest.c: Include "util.h". * src/xen_internal.c: Likewise. * src/qemu_conf.c (qemudCapsInit): Use ARRAY_CARDINALITY. * src/storage_backend.c (virStorageBackendForType): Likewise. * src/storage_backend_fs.c (virStorageBackendProbeFile): Likewise. * src/xen_internal.c (xenHypervisorMakeCapabilitiesInternal): Likewise. * src/xend_internal.c (xenDaemonParseSxpr): Likewise. * tests/nodeinfotest.c (mymain): Likewise. * tests/qparamtest.c (DO_TEST): Likewise.
This commit is contained in:
parent
b172c22997
commit
05589b72c4
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Mon Oct 27 17:14:56 +0100 2008 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
use ARRAY_CARDINALITY more
|
||||
* tests/nodeinfotest.c: Include "util.h".
|
||||
* src/xen_internal.c: Likewise.
|
||||
* src/qemu_conf.c (qemudCapsInit): Use ARRAY_CARDINALITY.
|
||||
* src/storage_backend.c (virStorageBackendForType): Likewise.
|
||||
* src/storage_backend_fs.c (virStorageBackendProbeFile): Likewise.
|
||||
* src/xen_internal.c (xenHypervisorMakeCapabilitiesInternal): Likewise.
|
||||
* src/xend_internal.c (xenDaemonParseSxpr): Likewise.
|
||||
* tests/nodeinfotest.c (mymain): Likewise.
|
||||
* tests/qparamtest.c (DO_TEST): Likewise.
|
||||
|
||||
Mon Oct 27 17:14:56 +0100 2008 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
exempt gnulib from write-avoidance syntax check
|
||||
|
|
|
@ -371,7 +371,7 @@ virCapsPtr qemudCapsInit(void) {
|
|||
if (qemudCapsInitNUMA(caps) < 0)
|
||||
goto no_memory;
|
||||
|
||||
for (i = 0 ; i < (sizeof(arch_info_hvm)/sizeof(arch_info_hvm[0])) ; i++)
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(arch_info_hvm) ; i++)
|
||||
if (qemudCapsInitGuest(caps,
|
||||
utsname.machine,
|
||||
&arch_info_hvm[i], 1) < 0)
|
||||
|
@ -379,7 +379,7 @@ virCapsPtr qemudCapsInit(void) {
|
|||
|
||||
if (access("/usr/bin/xenner", X_OK) == 0 &&
|
||||
access("/dev/kvm", F_OK) == 0) {
|
||||
for (i = 0 ; i < (sizeof(arch_info_xen)/sizeof(arch_info_xen[0])) ; i++)
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(arch_info_xen) ; i++)
|
||||
/* Allow Xen 32-on-32, 32-on-64 and 64-on-64 */
|
||||
if (STREQ(arch_info_xen[i].arch, utsname.machine) ||
|
||||
(STREQ(utsname.machine, "x86_64") &&
|
||||
|
|
|
@ -88,7 +88,7 @@ static virStorageBackendPtr backends[] = {
|
|||
virStorageBackendPtr
|
||||
virStorageBackendForType(int type) {
|
||||
unsigned int i;
|
||||
for (i = 0 ; i < (sizeof(backends)/sizeof(backends[0])) ; i++)
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(backends); i++)
|
||||
if (backends[i]->type == type)
|
||||
return backends[i];
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ static int virStorageBackendProbeFile(virConnectPtr conn,
|
|||
close(fd);
|
||||
|
||||
/* First check file magic */
|
||||
for (i = 0 ; i < sizeof(fileTypeInfo)/sizeof(fileTypeInfo[0]) ; i++) {
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(fileTypeInfo) ; i++) {
|
||||
int mlen;
|
||||
if (fileTypeInfo[i].magic == NULL)
|
||||
continue;
|
||||
|
@ -276,7 +276,7 @@ static int virStorageBackendProbeFile(virConnectPtr conn,
|
|||
}
|
||||
|
||||
/* No magic, so check file extension */
|
||||
for (i = 0 ; i < sizeof(fileTypeInfo)/sizeof(fileTypeInfo[0]) ; i++) {
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(fileTypeInfo) ; i++) {
|
||||
if (fileTypeInfo[i].extension == NULL)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "xs_internal.h"
|
||||
#include "stats_linux.h"
|
||||
#include "xend_internal.h"
|
||||
#include "util.h"
|
||||
|
||||
/* required for dom0_getdomaininfo_t */
|
||||
#include <xen/dom0_ops.h>
|
||||
|
@ -2345,7 +2346,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
|
|||
}
|
||||
|
||||
/* Too many arch flavours - highly unlikely ! */
|
||||
if (i >= sizeof(guest_archs)/sizeof(guest_archs[0]))
|
||||
if (i >= ARRAY_CARDINALITY(guest_archs))
|
||||
continue;
|
||||
/* Didn't find a match, so create a new one */
|
||||
if (i == nr_guest_archs)
|
||||
|
|
|
@ -2312,7 +2312,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
|
|||
if (hvm) {
|
||||
const char *const fds[] = { "fda", "fdb" };
|
||||
int i;
|
||||
for (i = 0 ; i < sizeof(fds)/sizeof(fds[0]) ; i++) {
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(fds) ; i++) {
|
||||
tmp = sexpr_fmt_node(root, "domain/image/hvm/%s", fds[i]);
|
||||
if ((tmp != NULL) && (tmp[0] != 0)) {
|
||||
virDomainDiskDefPtr disk;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "testutils.h"
|
||||
#include "internal.h"
|
||||
#include "nodeinfo.h"
|
||||
#include "util.h"
|
||||
|
||||
static char *progname;
|
||||
static char *abs_srcdir;
|
||||
|
@ -95,7 +96,7 @@ mymain(int argc, char **argv)
|
|||
|
||||
virInitialize();
|
||||
|
||||
for (i = 0 ; i < (sizeof(nodeData)/sizeof(nodeData[0])) ; i++)
|
||||
for (i = 0 ; i < ARRAY_CARDINALITY(nodeData); i++)
|
||||
if (virtTestRun(nodeData[i], 1, linuxTestNodeInfo, nodeData[i]) != 0)
|
||||
ret = -1;
|
||||
#endif
|
||||
|
|
|
@ -193,7 +193,7 @@ mymain(int argc ATTRIBUTE_UNUSED,
|
|||
struct qparamParseData info = { \
|
||||
queryIn, \
|
||||
queryOut ? queryOut : queryIn, \
|
||||
sizeof(params)/sizeof(params[0]), \
|
||||
ARRAY_CARDINALITY(params), \
|
||||
params }; \
|
||||
if (virtTestRun("Parse " queryIn, \
|
||||
1, qparamParseTest, &info) < 0) \
|
||||
|
|
Loading…
Reference in New Issue