Use G_N_ELEMENTS instead of ARRAY_CARDINALITY

Prefer the GLib version of the macro.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2019-10-15 13:55:26 +02:00
parent d99f17a502
commit 67e72053c1
110 changed files with 324 additions and 319 deletions

View File

@ -634,6 +634,12 @@ sc_prohibit_attribute_macros:
halt='use GLib macros: G_GNUC_<ATTRIBUTE_SUFFIX> for most' \
$(_sc_search_regexp)
sc_prohibit_non_glib_macros:
@prohibit='ARRAY_CARDINALITY' \
in_vc_files='\.[ch]$$' \
halt='use GLib macros: G_N_ELEMENTS' \
$(_sc_search_regexp)
sc_prohibit_int_index:
@prohibit='\<(int|unsigned)\s*\*?index\>(\s|,|;)' \
halt='use different name than 'index' for declaration' \

View File

@ -118,7 +118,7 @@ static virAccessDriverPtr accessDrivers[] = {
static virAccessDriverPtr virAccessManagerFindDriver(const char *name)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(accessDrivers); i++) {
for (i = 0; i < G_N_ELEMENTS(accessDrivers); i++) {
if (STREQ(name, accessDrivers[i]->name))
return accessDrivers[i];
}

View File

@ -215,7 +215,7 @@ virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
#define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \
do { \
unsigned int __values[] = {__VA_ARGS__}; \
size_t __nvalues = ARRAY_CARDINALITY(__values); \
size_t __nvalues = G_N_ELEMENTS(__values); \
virDomainCapsEnumSet(&(capsEnum), #capsEnum, \
__nvalues, __values); \
} while (0)

View File

@ -29809,7 +29809,7 @@ virDomainNetSetModelString(virDomainNetDefPtr net,
if (!model)
return 0;
for (i = 0; i < ARRAY_CARDINALITY(virDomainNetModelTypeList); i++) {
for (i = 0; i < G_N_ELEMENTS(virDomainNetModelTypeList); i++) {
if (STRCASEEQ(virDomainNetModelTypeList[i], model)) {
net->model = i;
return 0;

View File

@ -309,7 +309,7 @@ static virStoragePoolTypeInfoPtr
virStoragePoolTypeInfoLookup(int type)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(poolTypeInfo); i++)
for (i = 0; i < G_N_ELEMENTS(poolTypeInfo); i++)
if (poolTypeInfo[i].poolType == type)
return &poolTypeInfo[i];

View File

@ -131,7 +131,7 @@ virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(map); i++) {
for (i = 0; i < G_N_ELEMENTS(map); i++) {
if (flags & map[i].snap_flag) {
flags &= ~map[i].snap_flag;
moment_flags |= map[i].moment_flag;

View File

@ -57,7 +57,7 @@ cpuGetSubDriver(virArch arch)
return NULL;
}
for (i = 0; i < ARRAY_CARDINALITY(drivers); i++) {
for (i = 0; i < G_N_ELEMENTS(drivers); i++) {
for (j = 0; j < drivers[i]->narch; j++) {
if (arch == drivers[i]->arch[j])
return drivers[i];
@ -76,7 +76,7 @@ cpuGetSubDriverByName(const char *name)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(drivers); i++) {
for (i = 0; i < G_N_ELEMENTS(drivers); i++) {
if (STREQ_NULLABLE(name, drivers[i]->name))
return drivers[i];
}

View File

@ -101,7 +101,7 @@ virCPUarmCompare(virCPUDefPtr host G_GNUC_UNUSED,
struct cpuArchDriver cpuDriverArm = {
.name = "arm",
.arch = archs,
.narch = ARRAY_CARDINALITY(archs),
.narch = G_N_ELEMENTS(archs),
.compare = virCPUarmCompare,
.decode = NULL,
.encode = NULL,

View File

@ -452,7 +452,7 @@ ppc64Compute(virCPUDefPtr host,
if (cpu->arch != VIR_ARCH_NONE) {
bool found = false;
for (i = 0; i < ARRAY_CARDINALITY(archs); i++) {
for (i = 0; i < G_N_ELEMENTS(archs); i++) {
if (archs[i] == cpu->arch) {
found = true;
break;
@ -824,7 +824,7 @@ virCPUppc64DriverGetModels(char ***models)
struct cpuArchDriver cpuDriverPPC64 = {
.name = "ppc64",
.arch = archs,
.narch = ARRAY_CARDINALITY(archs),
.narch = G_N_ELEMENTS(archs),
.compare = virCPUppc64Compare,
.decode = ppc64DriverDecode,
.encode = NULL,

View File

@ -114,7 +114,7 @@ virCPUs390ValidateFeatures(virCPUDefPtr cpu)
struct cpuArchDriver cpuDriverS390 = {
.name = "s390",
.arch = archs,
.narch = ARRAY_CARDINALITY(archs),
.narch = G_N_ELEMENTS(archs),
.compare = virCPUs390Compare,
.decode = NULL,
.encode = NULL,

View File

@ -68,7 +68,7 @@ struct _virCPUx86Feature {
{ \
.name = (char *) Name, \
.data = { \
.len = ARRAY_CARDINALITY(Name ## _data), \
.len = G_N_ELEMENTS(Name ## _data), \
.items = Name ## _data, \
} \
}
@ -364,7 +364,7 @@ static virCPUx86FeaturePtr
x86FeatureFindInternal(const char *name)
{
size_t i;
size_t count = ARRAY_CARDINALITY(x86_kvm_features);
size_t count = G_N_ELEMENTS(x86_kvm_features);
for (i = 0; i < count; i++) {
if (STREQ(x86_kvm_features[i].name, name))
@ -1757,7 +1757,7 @@ x86Compute(virCPUDefPtr host,
if (cpu->arch != VIR_ARCH_NONE) {
bool found = false;
for (i = 0; i < ARRAY_CARDINALITY(archs); i++) {
for (i = 0; i < G_N_ELEMENTS(archs); i++) {
if (archs[i] == cpu->arch) {
found = true;
break;
@ -3422,7 +3422,7 @@ virCPUx86FeatureFilterDropMSR(const char *name,
struct cpuArchDriver cpuDriverX86 = {
.name = "x86",
.arch = archs,
.narch = ARRAY_CARDINALITY(archs),
.narch = G_N_ELEMENTS(archs),
.compare = virCPUx86Compare,
.decode = x86DecodeCPUData,
.encode = x86Encode,

View File

@ -547,7 +547,7 @@ ESX_VI__TEMPLATE__FREE(SharedCURL,
if (item->handle)
curl_share_cleanup(item->handle);
for (i = 0; i < ARRAY_CARDINALITY(item->locks); ++i)
for (i = 0; i < G_N_ELEMENTS(item->locks); ++i)
virMutexDestroy(&item->locks[i]);
})
@ -587,7 +587,7 @@ esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_CURL *curl)
curl_share_setopt(shared->handle, CURLSHOPT_SHARE,
CURL_LOCK_DATA_DNS);
for (i = 0; i < ARRAY_CARDINALITY(shared->locks); ++i) {
for (i = 0; i < G_N_ELEMENTS(shared->locks); ++i) {
if (virMutexInit(&shared->locks[i]) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize a CURL (share) mutex"));

View File

@ -91,7 +91,6 @@
((a) ? !(b) || STRNEQ((a), (b)) : !!(b))
#define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
#define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
/**
* G_GNUC_NO_INLINE:

View File

@ -3323,7 +3323,7 @@ virDomainMigrateUnmanagedProto2(virDomainPtr domain,
unsigned long long bandwidth = 0;
if (!virTypedParamsCheck(params, nparams, compatParams,
ARRAY_CARDINALITY(compatParams))) {
G_N_ELEMENTS(compatParams))) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Some parameters are not supported by migration "
"protocol 2"));
@ -3372,7 +3372,7 @@ virDomainMigrateUnmanagedProto3(virDomainPtr domain,
unsigned long long bandwidth = 0;
if (!virTypedParamsCheck(params, nparams, compatParams,
ARRAY_CARDINALITY(compatParams))) {
G_N_ELEMENTS(compatParams))) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Some parameters are not supported by migration "
"protocol 3"));
@ -3933,7 +3933,7 @@ virDomainMigrate3(virDomainPtr domain,
}
if (!virTypedParamsCheck(params, nparams, compatParams,
ARRAY_CARDINALITY(compatParams))) {
G_N_ELEMENTS(compatParams))) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Migration APIs with extensible parameters are not "
"supported but extended parameters were passed"));

View File

@ -1551,7 +1551,7 @@ virNodeGetCPUMap(virConnectPtr conn,
* Example how to use this API:
*
* unsigned int pages[] = { 4, 2048, 1048576}
* unsigned int npages = ARRAY_CARDINALITY(pages);
* unsigned int npages = G_N_ELEMENTS(pages);
* int startcell = 0;
* unsigned int cellcount = 2;
*

View File

@ -134,11 +134,11 @@ libxlCapsNodeData(virCPUDefPtr cpu, libxl_hwcap hwcap,
if (!(cpudata = virCPUDataNew(cpu->arch)))
goto error;
ncaps = ARRAY_CARDINALITY(cpuid);
ncaps = G_N_ELEMENTS(cpuid);
if (libxlCapsAddCPUID(cpudata, cpuid, ncaps) < 0)
goto error;
ncaps = ARRAY_CARDINALITY(cpuid_ver1);
ncaps = G_N_ELEMENTS(cpuid_ver1);
if (version > LIBXL_HWCAP_V0 &&
libxlCapsAddCPUID(cpudata, cpuid_ver1, ncaps) < 0)
goto error;
@ -471,7 +471,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
}
/* Too many arch flavours - highly unlikely ! */
if (i >= ARRAY_CARDINALITY(guest_archs))
if (i >= G_N_ELEMENTS(guest_archs))
continue;
/* Didn't find a match, so create a new one */
if (i == nr_guest_archs)
@ -500,7 +500,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
#ifdef HAVE_XEN_PVH
if (hvm && i == nr_guest_archs-1) {
/* Ensure we have not exhausted the guest_archs array */
if (nr_guest_archs >= ARRAY_CARDINALITY(guest_archs))
if (nr_guest_archs >= G_N_ELEMENTS(guest_archs))
continue;
i = nr_guest_archs;
nr_guest_archs++;

View File

@ -5339,7 +5339,7 @@ libxlDiskPathToID(const char *virtpath)
fmt = id = -1;
/* Find any disk prefixes we know about */
for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) {
for (i = 0; i < G_N_ELEMENTS(drive_prefix); i++) {
if (STRPREFIX(virtpath, drive_prefix[i]) &&
!virDiskNameParse(virtpath, &disk, &partition)) {
fmt = i;

View File

@ -860,7 +860,7 @@ static void libxlTunnel3MigrationSrcFunc(void *arg)
fds[0].events = POLLIN;
fds[0].revents = 0;
ret = poll(fds, ARRAY_CARDINALITY(fds), timeout);
ret = poll(fds, G_N_ELEMENTS(fds), timeout);
if (ret < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;
@ -1138,7 +1138,7 @@ static int virConnectCredType[] = {
static virConnectAuth virConnectAuthConfig = {
.credtype = virConnectCredType,
.ncredtype = ARRAY_CARDINALITY(virConnectCredType),
.ncredtype = G_N_ELEMENTS(virConnectCredType),
};
/* On P2P mode there is only the Perform3 phase and we need to handle

View File

@ -250,7 +250,7 @@ xenTranslateCPUFeature(const char *feature_name, bool from_libxl)
};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(translation_table); i++)
for (i = 0; i < G_N_ELEMENTS(translation_table); i++)
if (STREQ(translation_table[i][from_libxl], feature_name))
return translation_table[i][!from_libxl];
return feature_name;

View File

@ -50,7 +50,7 @@ static int virDomainLockManagerAddLease(virLockManagerPtr lock,
.value = { .str = lease->lockspace },
},
};
size_t nparams = ARRAY_CARDINALITY(lparams);
size_t nparams = G_N_ELEMENTS(lparams);
if (!lease->lockspace)
nparams--;
@ -137,7 +137,7 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
if (!(lock = virLockManagerNew(virLockManagerPluginGetDriver(plugin),
VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN,
ARRAY_CARDINALITY(params),
G_N_ELEMENTS(params),
params,
flags)))
goto error;

View File

@ -314,7 +314,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
}
if (!(lockd->dmn = virNetDaemonNewPostExecRestart(child,
ARRAY_CARDINALITY(serverNames),
G_N_ELEMENTS(serverNames),
serverNames,
virLockDaemonNewServerPostExecRestart,
(void*)(intptr_t)(privileged ? 0x1 : 0x0))))
@ -1317,7 +1317,7 @@ int main(int argc, char **argv) {
}
if (virSystemdGetActivation(actmap,
ARRAY_CARDINALITY(actmap),
G_N_ELEMENTS(actmap),
&act) < 0) {
ret = VIR_LOCK_DAEMON_ERR_NETWORK;
goto cleanup;

View File

@ -63,7 +63,7 @@ main(int argc, char **argv)
};
virConnectAuth auth = {
.credtype = authTypes,
.ncredtype = ARRAY_CARDINALITY(authTypes),
.ncredtype = G_N_ELEMENTS(authTypes),
.cb = authCallback,
};

View File

@ -266,7 +266,7 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged,
}
if (!(logd->dmn = virNetDaemonNewPostExecRestart(child,
ARRAY_CARDINALITY(serverNames),
G_N_ELEMENTS(serverNames),
serverNames,
virLogDaemonNewServerPostExecRestart,
(void*)(intptr_t)(privileged ? 0x1 : 0x0))))
@ -1090,7 +1090,7 @@ int main(int argc, char **argv) {
}
if (virSystemdGetActivation(actmap,
ARRAY_CARDINALITY(actmap),
G_N_ELEMENTS(actmap),
&act) < 0) {
ret = VIR_LOG_DAEMON_ERR_NETWORK;
goto cleanup;

View File

@ -823,7 +823,7 @@ bool lxcIsBasicMountLocation(const char *path)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(lxcBasicMounts); i++) {
for (i = 0; i < G_N_ELEMENTS(lxcBasicMounts); i++) {
if (STREQ(path, lxcBasicMounts[i].dst))
return true;
}
@ -900,7 +900,7 @@ static int lxcContainerMountBasicFS(bool userns_enabled,
VIR_DEBUG("Mounting basic filesystems");
for (i = 0; i < ARRAY_CARDINALITY(lxcBasicMounts); i++) {
for (i = 0; i < G_N_ELEMENTS(lxcBasicMounts); i++) {
bool bindOverReadonly;
virLXCBasicMountInfo const *mnt = &lxcBasicMounts[i];
@ -1126,7 +1126,7 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
{ "/proc/self/fd", "/dev/fd" },
};
for (i = 0; i < ARRAY_CARDINALITY(links); i++) {
for (i = 0; i < G_N_ELEMENTS(links); i++) {
if (symlink(links[i].src, links[i].dst) < 0) {
virReportSystemError(errno,
_("Failed to symlink device %s to %s"),

View File

@ -1521,7 +1521,7 @@ static int virLXCControllerPopulateDevices(virLXCControllerPtr ctrl)
goto cleanup;
/* Populate /dev/ with a few important bits */
for (i = 0; i < ARRAY_CARDINALITY(devs); i++) {
for (i = 0; i < G_N_ELEMENTS(devs); i++) {
if (virAsprintf(&path, "/%s/%s.dev/%s",
LXC_STATE_DIR, ctrl->def->name, devs[i].path) < 0)
goto cleanup;

View File

@ -171,7 +171,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
if (!(mon->program = virNetClientProgramNew(VIR_LXC_MONITOR_PROGRAM,
VIR_LXC_MONITOR_PROGRAM_VERSION,
virLXCMonitorEvents,
ARRAY_CARDINALITY(virLXCMonitorEvents),
G_N_ELEMENTS(virLXCMonitorEvents),
mon)))
goto error;

View File

@ -362,7 +362,7 @@ gather_capability(LibHalContext *ctx, const char *udi,
{
caps_tbl_entry *entry;
entry = bsearch(&cap_name, caps_tbl, ARRAY_CARDINALITY(caps_tbl),
entry = bsearch(&cap_name, caps_tbl, G_N_ELEMENTS(caps_tbl),
sizeof(caps_tbl[0]), cmpstringp);
if (entry) {
@ -604,7 +604,7 @@ nodeStateInitialize(bool privileged G_GNUC_UNUSED,
DBusError err;
/* Ensure caps_tbl is sorted by capability name */
qsort(caps_tbl, ARRAY_CARDINALITY(caps_tbl), sizeof(caps_tbl[0]),
qsort(caps_tbl, G_N_ELEMENTS(caps_tbl), sizeof(caps_tbl[0]),
cmpstringp);
if (VIR_ALLOC(driver) < 0)

View File

@ -1425,7 +1425,7 @@ udevEnumerateAddMatches(struct udev_enumerate *udev_enumerate)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(subsystem_blacklist); i++) {
for (i = 0; i < G_N_ELEMENTS(subsystem_blacklist); i++) {
const char *s = subsystem_blacklist[i];
if (udev_enumerate_add_nomatch_subsystem(udev_enumerate, s) < 0) {
virReportSystemError(errno, "%s", _("failed to add susbsystem filter"));

View File

@ -1382,7 +1382,7 @@ virNWFilterDHCPSnoopThread(void *req0)
virNWFilterSnoopReqLock(req);
if (req->binding->portdevname && req->threadkey) {
for (i = 0; i < ARRAY_CARDINALITY(pcapConf); i++) {
for (i = 0; i < G_N_ELEMENTS(pcapConf); i++) {
pcapConf[i].handle =
virNWFilterSnoopDHCPOpen(req->binding->portdevname,
&req->binding->mac,
@ -1419,7 +1419,7 @@ virNWFilterDHCPSnoopThread(void *req0)
while (!error) {
if (virNWFilterSnoopAdjustPoll(pcapConf,
ARRAY_CARDINALITY(pcapConf),
G_N_ELEMENTS(pcapConf),
fds, &pollTo) < 0) {
break;
}
@ -1428,7 +1428,7 @@ virNWFilterDHCPSnoopThread(void *req0)
if (pollTo < 0 || pollTo > SNOOP_POLL_MAX_TIMEOUT_MS)
pollTo = SNOOP_POLL_MAX_TIMEOUT_MS;
n = poll(fds, ARRAY_CARDINALITY(fds), pollTo);
n = poll(fds, G_N_ELEMENTS(fds), pollTo);
if (n < 0) {
if (errno != EAGAIN && errno != EINTR)
@ -1445,7 +1445,7 @@ virNWFilterDHCPSnoopThread(void *req0)
req->jobCompletionStatus != 0)
goto exit;
for (i = 0; n > 0 && i < ARRAY_CARDINALITY(fds); i++) {
for (i = 0; n > 0 && i < G_N_ELEMENTS(fds); i++) {
if (!fds[i].revents)
continue;
@ -1567,7 +1567,7 @@ virNWFilterDHCPSnoopThread(void *req0)
VIR_FREE(threadkey);
for (i = 0; i < ARRAY_CARDINALITY(pcapConf); i++) {
for (i = 0; i < G_N_ELEMENTS(pcapConf); i++) {
if (pcapConf[i].handle)
pcap_close(pcapConf[i].handle);
}

View File

@ -479,7 +479,7 @@ learnIPAddressThread(void *arg)
pcap_freecode(&fp);
while (req->status == 0 && vmaddr == 0) {
int n = poll(fds, ARRAY_CARDINALITY(fds), PKT_TIMEOUT_MS);
int n = poll(fds, G_N_ELEMENTS(fds), PKT_TIMEOUT_MS);
if (threadsTerminate || req->terminate) {
req->status = ECANCELED;

View File

@ -127,7 +127,7 @@ waitsocket(int socket_fd, LIBSSH2_SESSION * session)
if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
fds[0].events |= POLLOUT;
return poll(fds, ARRAY_CARDINALITY(fds), -1);
return poll(fds, G_N_ELEMENTS(fds), -1);
}
/* this function is the layer that manipulates the ssh channel itself

View File

@ -264,7 +264,7 @@ qemuAgentIOProcessEvent(qemuAgentPtr mon,
}
/*
for (i = 0; i < ARRAY_CARDINALITY(eventHandlers); i++) {
for (i = 0; i < G_N_ELEMENTS(eventHandlers); i++) {
if (STREQ(eventHandlers[i].type, type)) {
virJSONValuePtr data = virJSONValueObjectGet(obj, "data");
VIR_DEBUG("handle %s handler=%p data=%p", type,

View File

@ -1313,103 +1313,103 @@ typedef int (*virQEMUCapsObjectTypePropsCB)(qemuMonitorPtr mon,
static virQEMUCapsObjectTypeProps virQEMUCapsDeviceProps[] = {
{ "virtio-blk-pci", virQEMUCapsDevicePropsVirtioBlk,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBlk),
-1 },
{ "virtio-net-pci", virQEMUCapsDevicePropsVirtioNet,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioNet),
QEMU_CAPS_DEVICE_VIRTIO_NET },
{ "virtio-scsi-pci", virQEMUCapsDevicePropsVirtioSCSI,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioSCSI),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioSCSI),
QEMU_CAPS_VIRTIO_SCSI },
{ "virtio-blk-ccw", virQEMUCapsDevicePropsVirtioBlk,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBlk),
QEMU_CAPS_VIRTIO_CCW },
{ "virtio-net-ccw", virQEMUCapsDevicePropsVirtioNet,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioNet),
QEMU_CAPS_DEVICE_VIRTIO_NET },
{ "virtio-scsi-ccw", virQEMUCapsDevicePropsVirtioSCSI,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioSCSI),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioSCSI),
QEMU_CAPS_VIRTIO_SCSI },
{ "virtio-blk-s390", virQEMUCapsDevicePropsVirtioBlk,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBlk),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBlk),
QEMU_CAPS_VIRTIO_S390 },
{ "virtio-net-s390", virQEMUCapsDevicePropsVirtioNet,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioNet),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioNet),
QEMU_CAPS_DEVICE_VIRTIO_NET },
{ "vfio-pci", virQEMUCapsDevicePropsVfioPCI,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVfioPCI),
G_N_ELEMENTS(virQEMUCapsDevicePropsVfioPCI),
QEMU_CAPS_DEVICE_VFIO_PCI },
{ "scsi-hd", virQEMUCapsDevicePropsSCSIDisk,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSCSIDisk),
G_N_ELEMENTS(virQEMUCapsDevicePropsSCSIDisk),
-1 },
{ "ide-hd", virQEMUCapsDevicePropsIDEDrive,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsIDEDrive),
G_N_ELEMENTS(virQEMUCapsDevicePropsIDEDrive),
-1 },
{ "PIIX4_PM", virQEMUCapsDevicePropsPiix4PM,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsPiix4PM),
G_N_ELEMENTS(virQEMUCapsDevicePropsPiix4PM),
-1 },
{ "usb-redir", virQEMUCapsDevicePropsUSBRedir,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBRedir),
G_N_ELEMENTS(virQEMUCapsDevicePropsUSBRedir),
QEMU_CAPS_USB_REDIR },
{ "i440FX-pcihost", virQEMUCapsDevicePropsI440FXPCIHost,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsI440FXPCIHost),
G_N_ELEMENTS(virQEMUCapsDevicePropsI440FXPCIHost),
-1 },
{ "q35-pcihost", virQEMUCapsDevicePropsQ35PCIHost,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsQ35PCIHost),
G_N_ELEMENTS(virQEMUCapsDevicePropsQ35PCIHost),
-1 },
{ "usb-storage", virQEMUCapsDevicePropsUSBStorage,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBStorage),
G_N_ELEMENTS(virQEMUCapsDevicePropsUSBStorage),
QEMU_CAPS_DEVICE_USB_STORAGE },
{ "kvm-pit", virQEMUCapsDevicePropsKVMPit,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsKVMPit),
G_N_ELEMENTS(virQEMUCapsDevicePropsKVMPit),
-1 },
{ "VGA", virQEMUCapsDevicePropsVGA,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVGA),
G_N_ELEMENTS(virQEMUCapsDevicePropsVGA),
QEMU_CAPS_DEVICE_VGA },
{ "vmware-svga", virQEMUCapsDevicePropsVmwareSvga,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVmwareSvga),
G_N_ELEMENTS(virQEMUCapsDevicePropsVmwareSvga),
QEMU_CAPS_DEVICE_VMWARE_SVGA },
{ "qxl", virQEMUCapsDevicePropsQxl,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsQxl),
G_N_ELEMENTS(virQEMUCapsDevicePropsQxl),
QEMU_CAPS_DEVICE_QXL },
{ "virtio-gpu-pci", virQEMUCapsDevicePropsVirtioGpu,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioGpu),
QEMU_CAPS_DEVICE_VIRTIO_GPU },
{ "virtio-gpu-device", virQEMUCapsDevicePropsVirtioGpu,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioGpu),
QEMU_CAPS_DEVICE_VIRTIO_GPU },
{ "ICH9-LPC", virQEMUCapsDevicePropsICH9,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsICH9),
G_N_ELEMENTS(virQEMUCapsDevicePropsICH9),
-1 },
{ "virtio-balloon-pci", virQEMUCapsDevicePropsVirtioBalloon,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBalloon),
-1 },
{ "virtio-balloon-ccw", virQEMUCapsDevicePropsVirtioBalloon,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBalloon),
-1 },
{ "virtio-balloon-device", virQEMUCapsDevicePropsVirtioBalloon,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioBalloon),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioBalloon),
-1 },
{ "nec-usb-xhci", virQEMUCapsDevicePropsUSBNECXHCI,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsUSBNECXHCI),
G_N_ELEMENTS(virQEMUCapsDevicePropsUSBNECXHCI),
QEMU_CAPS_NEC_USB_XHCI },
{ "intel-iommu", virQEMUCapsDevicePropsIntelIOMMU,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsIntelIOMMU),
G_N_ELEMENTS(virQEMUCapsDevicePropsIntelIOMMU),
QEMU_CAPS_DEVICE_INTEL_IOMMU },
{ "spapr-pci-host-bridge", virQEMUCapsDevicePropsSpaprPCIHostBridge,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsSpaprPCIHostBridge),
G_N_ELEMENTS(virQEMUCapsDevicePropsSpaprPCIHostBridge),
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
{ "virtio-gpu-ccw", virQEMUCapsDevicePropsVirtioGpu,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
G_N_ELEMENTS(virQEMUCapsDevicePropsVirtioGpu),
QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW },
{ "virtual-css-bridge", virQEMUCapsObjectPropsVirtualCSSBridge,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtualCSSBridge),
G_N_ELEMENTS(virQEMUCapsObjectPropsVirtualCSSBridge),
QEMU_CAPS_CCW },
{ "mch", virQEMUCapsDevicePropsMCH,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsMCH),
G_N_ELEMENTS(virQEMUCapsDevicePropsMCH),
QEMU_CAPS_DEVICE_MCH },
{ "nvdimm", virQEMUCapsDevicePropsNVDIMM,
ARRAY_CARDINALITY(virQEMUCapsDevicePropsNVDIMM),
G_N_ELEMENTS(virQEMUCapsDevicePropsNVDIMM),
QEMU_CAPS_DEVICE_NVDIMM },
};
@ -1429,13 +1429,13 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMaxX86CPU[] = {
static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
{ "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendFile),
G_N_ELEMENTS(virQEMUCapsObjectPropsMemoryBackendFile),
QEMU_CAPS_OBJECT_MEMORY_FILE },
{ "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendMemfd),
G_N_ELEMENTS(virQEMUCapsObjectPropsMemoryBackendMemfd),
QEMU_CAPS_OBJECT_MEMORY_MEMFD },
{ "max-x86_64-cpu", virQEMUCapsObjectPropsMaxX86CPU,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMaxX86CPU),
G_N_ELEMENTS(virQEMUCapsObjectPropsMaxX86CPU),
QEMU_CAPS_X86_MAX_CPU },
};
@ -1452,10 +1452,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsVirt[] = {
static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
{ "pseries", virQEMUCapsMachinePropsPSeries,
ARRAY_CARDINALITY(virQEMUCapsMachinePropsPSeries),
G_N_ELEMENTS(virQEMUCapsMachinePropsPSeries),
-1 },
{ "virt", virQEMUCapsMachinePropsVirt,
ARRAY_CARDINALITY(virQEMUCapsMachinePropsVirt),
G_N_ELEMENTS(virQEMUCapsMachinePropsVirt),
-1 },
};
@ -2171,7 +2171,7 @@ virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps,
return -1;
virQEMUCapsProcessStringFlags(qemuCaps,
ARRAY_CARDINALITY(virQEMUCapsCommands),
G_N_ELEMENTS(virQEMUCapsCommands),
virQEMUCapsCommands,
ncommands, commands);
virStringListFreeCount(commands, ncommands);
@ -2201,7 +2201,7 @@ virQEMUCapsProbeQMPEvents(virQEMUCapsPtr qemuCaps,
return -1;
virQEMUCapsProcessStringFlags(qemuCaps,
ARRAY_CARDINALITY(virQEMUCapsEvents),
G_N_ELEMENTS(virQEMUCapsEvents),
virQEMUCapsEvents,
nevents, events);
virStringListFreeCount(events, nevents);
@ -2249,7 +2249,7 @@ virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
return -1;
virQEMUCapsProcessStringFlags(qemuCaps,
ARRAY_CARDINALITY(virQEMUCapsObjectTypes),
G_N_ELEMENTS(virQEMUCapsObjectTypes),
virQEMUCapsObjectTypes,
nvalues, values);
virStringListFreeCount(values, nvalues);
@ -2257,7 +2257,7 @@ virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
if (virQEMUCapsProbeQMPGenericProps(qemuCaps,
mon,
virQEMUCapsDeviceProps,
ARRAY_CARDINALITY(virQEMUCapsDeviceProps),
G_N_ELEMENTS(virQEMUCapsDeviceProps),
qemuMonitorGetDeviceProps) < 0)
return -1;
@ -2265,7 +2265,7 @@ virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
virQEMUCapsProbeQMPGenericProps(qemuCaps,
mon,
virQEMUCapsObjectProps,
ARRAY_CARDINALITY(virQEMUCapsObjectProps),
G_N_ELEMENTS(virQEMUCapsObjectProps),
qemuMonitorGetObjectProps) < 0)
return -1;
@ -2330,7 +2330,7 @@ static const char *preferredMachines[] =
"sim", /* VIR_ARCH_XTENSA */
"sim", /* VIR_ARCH_XTENSAEB */
};
verify(ARRAY_CARDINALITY(preferredMachines) == VIR_ARCH_LAST);
verify(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST);
static int
@ -2412,7 +2412,7 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
return 0;
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineProps); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineProps); i++) {
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, props.type);
VIR_AUTOFREE(char *) type = NULL;
@ -2717,7 +2717,7 @@ virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
return -1;
if (nentries > 0) {
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsTPMModelsToCaps); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMModelsToCaps); i++) {
const char *needle = virDomainTPMModelTypeToString(
virQEMUCapsTPMModelsToCaps[i].type);
if (virStringListHasString((const char **)entries, needle))
@ -2731,7 +2731,7 @@ virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
return -1;
if (nentries > 0) {
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsTPMTypesToCaps); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMTypesToCaps); i++) {
const char *needle = virDomainTPMBackendTypeToString(
virQEMUCapsTPMTypesToCaps[i].type);
if (virStringListHasString((const char **)entries, needle))
@ -2808,7 +2808,7 @@ virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
char **values;
size_t i, j;
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsCommandLine); i++) {
if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
virQEMUCapsCommandLine[i].option,
&values,
@ -2841,7 +2841,7 @@ virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCapsPtr qemuCaps,
return -1;
virQEMUCapsProcessStringFlags(qemuCaps,
ARRAY_CARDINALITY(virQEMUCapsMigration),
G_N_ELEMENTS(virQEMUCapsMigration),
virQEMUCapsMigration,
ncaps, caps);
virStringListFreeCount(caps, ncaps);
@ -4155,7 +4155,7 @@ virQEMUCapsKVMSupportsNesting(void)
int rc;
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(kmod); i++) {
for (i = 0; i < G_N_ELEMENTS(kmod); i++) {
VIR_FREE(value);
rc = virFileReadValueString(&value, "/sys/module/%s/parameters/nested",
kmod[i]);
@ -4513,7 +4513,7 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps,
return -1;
schemareply = NULL;
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsQMPSchemaQueries); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsQMPSchemaQueries); i++) {
entry = virQEMUCapsQMPSchemaQueries + i;
if (virQEMUQAPISchemaPathExists(entry->value, schema))
@ -4521,7 +4521,7 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps,
}
/* probe also for basic event support */
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsEvents); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsEvents); i++) {
entry = virQEMUCapsEvents + i;
if (virQEMUQAPISchemaPathExists(entry->value, schema))
@ -4816,7 +4816,7 @@ struct virQEMUCapsMachineTypeFilter {
static const struct virQEMUCapsMachineTypeFilter virQEMUCapsMachineFilter[] = {
/* { "blah", virQEMUCapsMachineBLAHFilter,
ARRAY_CARDINALITY(virQEMUCapsMachineBLAHFilter) }, */
G_N_ELEMENTS(virQEMUCapsMachineBLAHFilter) }, */
{ "", NULL, 0 },
};
@ -4830,7 +4830,7 @@ virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
if (!machineType)
return;
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineFilter); i++) {
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineFilter); i++) {
const struct virQEMUCapsMachineTypeFilter *filter = &virQEMUCapsMachineFilter[i];
size_t j;
@ -4977,8 +4977,8 @@ virQEMUCapsCacheLookupByArch(virFileCachePtr cache,
priv->microcodeVersion = virHostCPUGetMicrocodeVersion();
for (i = 0; i < ARRAY_CARDINALITY(binaryFilters); i++) {
for (j = 0; j < ARRAY_CARDINALITY(archs); j++) {
for (i = 0; i < G_N_ELEMENTS(binaryFilters); i++) {
for (j = 0; j < G_N_ELEMENTS(archs); j++) {
struct virQEMUCapsSearchData data = {
.arch = archs[j],
.binaryFilter = binaryFilters[i],

View File

@ -3234,7 +3234,7 @@ qemuBuildControllersCommandLine(virCommandPtr cmd,
VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
};
for (i = 0; i < ARRAY_CARDINALITY(contOrder); i++) {
for (i = 0; i < G_N_ELEMENTS(contOrder); i++) {
if (qemuBuildControllersByTypeCommandLine(cmd, def, qemuCaps, contOrder[i]) < 0)
return -1;
}

View File

@ -1280,7 +1280,7 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
VIR_STRDUP(sm->doi, doi) < 0)
return NULL;
for (j = 0; j < ARRAY_CARDINALITY(virtTypes); j++) {
for (j = 0; j < G_N_ELEMENTS(virtTypes); j++) {
lbl = qemuSecurityGetBaseLabel(sec_managers[i], virtTypes[j]);
type = virDomainVirtTypeToString(virtTypes[j]);
if (lbl &&

View File

@ -11712,7 +11712,7 @@ ppc64VFIODeviceIsNV2Bridge(const char *device)
"ibm,nvlink-speed", "memory-region"};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(nvlink2Files); i++) {
for (i = 0; i < G_N_ELEMENTS(nvlink2Files); i++) {
VIR_AUTOFREE(char *) file = NULL;
if ((virAsprintf(&file, "/sys/bus/pci/devices/%s/of_node/%s",

View File

@ -3149,7 +3149,7 @@ static void qemuMigrationSrcIOFunc(void *arg)
fds[0].events = fds[1].events = POLLIN;
fds[0].revents = fds[1].revents = 0;
ret = poll(fds, ARRAY_CARDINALITY(fds), timeout);
ret = poll(fds, G_N_ELEMENTS(fds), timeout);
if (ret < 0) {
if (errno == EAGAIN || errno == EINTR)
@ -4395,7 +4395,7 @@ static int virConnectCredType[] = {
static virConnectAuth virConnectAuthConfig = {
.credtype = virConnectCredType,
.ncredtype = ARRAY_CARDINALITY(virConnectCredType),
.ncredtype = G_N_ELEMENTS(virConnectCredType),
};

View File

@ -214,7 +214,7 @@ static const qemuMigrationParamType qemuMigrationParamTypes[] = {
[QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH] = QEMU_MIGRATION_PARAM_TYPE_ULL,
[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS] = QEMU_MIGRATION_PARAM_TYPE_INT,
};
verify(ARRAY_CARDINALITY(qemuMigrationParamTypes) == QEMU_MIGRATION_PARAM_LAST);
verify(G_N_ELEMENTS(qemuMigrationParamTypes) == QEMU_MIGRATION_PARAM_LAST);
virBitmapPtr
@ -226,7 +226,7 @@ qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty party)
if (!(caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST)))
return NULL;
for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsAlwaysOn); i++) {
for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsAlwaysOn); i++) {
if (!(qemuMigrationParamsAlwaysOn[i].party & party))
continue;
@ -500,7 +500,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
if (!(migParams = qemuMigrationParamsNew()))
return NULL;
for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsFlagMap); i++) {
for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsFlagMap); i++) {
qemuMigrationCapability cap = qemuMigrationParamsFlagMap[i].cap;
if (qemuMigrationParamsFlagMap[i].party & party &&
@ -511,7 +511,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
}
}
for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsTPMap); i++) {
for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsTPMap); i++) {
const qemuMigrationParamsTPMapItem *item = &qemuMigrationParamsTPMap[i];
if (!(item->party & party))
@ -590,7 +590,7 @@ qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
return -1;
}
for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsTPMap); i++) {
for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsTPMap); i++) {
const qemuMigrationParamsTPMapItem *item = &qemuMigrationParamsTPMap[i];
if (!(item->party & QEMU_MIGRATION_DESTINATION))
@ -1149,7 +1149,7 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver,
}
}
for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsAlwaysOn); i++) {
for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsAlwaysOn); i++) {
cap = qemuMigrationParamsAlwaysOn[i].cap;
if (qemuMigrationParamsAlwaysOn[i].party & party &&

View File

@ -200,7 +200,7 @@ qemuMonitorJSONIOProcessEvent(qemuMonitorPtr mon,
qemuMonitorEmitEvent(mon, type, seconds, micros, details);
VIR_FREE(details);
handler = bsearch(type, eventHandlers, ARRAY_CARDINALITY(eventHandlers),
handler = bsearch(type, eventHandlers, G_N_ELEMENTS(eventHandlers),
sizeof(eventHandlers[0]), qemuMonitorEventCompare);
if (handler) {
VIR_DEBUG("handle %s handler=%p data=%p", type,

View File

@ -357,7 +357,7 @@ virQEMUQAPISchemaTraverse(const char *baseName,
if (!(metatype = virJSONValueObjectGetString(cur, "meta-type")))
return -2;
for (i = 0; i < ARRAY_CARDINALITY(traverseMetaType); i++) {
for (i = 0; i < G_N_ELEMENTS(traverseMetaType); i++) {
if (STREQ(metatype, traverseMetaType[i].metatype))
return traverseMetaType[i].func(cur, ctxt);
}

View File

@ -419,7 +419,7 @@ daemonSetupNetworking(virNetServerPtr srv,
return -1;
#endif /* ! WITH_IP */
if (virSystemdGetActivation(actmap, ARRAY_CARDINALITY(actmap), &act) < 0)
if (virSystemdGetActivation(actmap, G_N_ELEMENTS(actmap), &act) < 0)
return -1;
#ifdef WITH_IP
@ -955,7 +955,7 @@ daemonUsage(const char *argv0, bool privileged)
fprintf(stderr, "\n");
fprintf(stderr, "%s\n", _("Options:"));
for (i = 0; i < ARRAY_CARDINALITY(opthelp); i++)
for (i = 0; i < G_N_ELEMENTS(opthelp); i++)
fprintf(stderr, " %-22s %s\n", opthelp[i].opts,
_(opthelp[i].help));
fprintf(stderr, "\n");

View File

@ -1493,7 +1493,7 @@ static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockThreshold),
};
verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
verify(G_N_ELEMENTS(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
static int
remoteRelayNetworkEventLifecycle(virConnectPtr conn,
@ -1536,7 +1536,7 @@ static virConnectNetworkEventGenericCallback networkEventCallbacks[] = {
VIR_NETWORK_EVENT_CALLBACK(remoteRelayNetworkEventLifecycle),
};
verify(ARRAY_CARDINALITY(networkEventCallbacks) == VIR_NETWORK_EVENT_ID_LAST);
verify(G_N_ELEMENTS(networkEventCallbacks) == VIR_NETWORK_EVENT_ID_LAST);
static int
remoteRelayStoragePoolEventLifecycle(virConnectPtr conn,
@ -1615,7 +1615,7 @@ static virConnectStoragePoolEventGenericCallback storageEventCallbacks[] = {
VIR_STORAGE_POOL_EVENT_CALLBACK(remoteRelayStoragePoolEventRefresh),
};
verify(ARRAY_CARDINALITY(storageEventCallbacks) == VIR_STORAGE_POOL_EVENT_ID_LAST);
verify(G_N_ELEMENTS(storageEventCallbacks) == VIR_STORAGE_POOL_EVENT_ID_LAST);
static int
remoteRelayNodeDeviceEventLifecycle(virConnectPtr conn,
@ -1694,7 +1694,7 @@ static virConnectNodeDeviceEventGenericCallback nodeDeviceEventCallbacks[] = {
VIR_NODE_DEVICE_EVENT_CALLBACK(remoteRelayNodeDeviceEventUpdate),
};
verify(ARRAY_CARDINALITY(nodeDeviceEventCallbacks) == VIR_NODE_DEVICE_EVENT_ID_LAST);
verify(G_N_ELEMENTS(nodeDeviceEventCallbacks) == VIR_NODE_DEVICE_EVENT_ID_LAST);
static int
remoteRelaySecretEventLifecycle(virConnectPtr conn,
@ -1773,7 +1773,7 @@ static virConnectSecretEventGenericCallback secretEventCallbacks[] = {
VIR_SECRET_EVENT_CALLBACK(remoteRelaySecretEventValueChanged),
};
verify(ARRAY_CARDINALITY(secretEventCallbacks) == VIR_SECRET_EVENT_ID_LAST);
verify(G_N_ELEMENTS(secretEventCallbacks) == VIR_SECRET_EVENT_ID_LAST);
static void
remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
@ -2176,7 +2176,7 @@ remoteDispatchProbeURI(bool readonly,
};
ssize_t i;
for (i = 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) {
VIR_AUTOFREE(char *) daemonname = NULL;
VIR_AUTOFREE(char *) daemonpath = NULL;
@ -2222,7 +2222,7 @@ remoteDispatchProbeURI(bool readonly,
};
ssize_t i;
for (i = 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) {
VIR_AUTOFREE(char *) sockname = NULL;
if (virAsprintf(&sockname, "%s/libvirt/virt%sd-%s",

View File

@ -1313,7 +1313,7 @@ doRemoteOpen(virConnectPtr conn,
if (!(priv->remoteProgram = virNetClientProgramNew(REMOTE_PROGRAM,
REMOTE_PROTOCOL_VERSION,
remoteEvents,
ARRAY_CARDINALITY(remoteEvents),
G_N_ELEMENTS(remoteEvents),
conn)))
goto failed;
if (!(priv->lxcProgram = virNetClientProgramNew(LXC_PROGRAM,
@ -1325,7 +1325,7 @@ doRemoteOpen(virConnectPtr conn,
if (!(priv->qemuProgram = virNetClientProgramNew(QEMU_PROGRAM,
QEMU_PROTOCOL_VERSION,
qemuEvents,
ARRAY_CARDINALITY(qemuEvents),
G_N_ELEMENTS(qemuEvents),
conn)))
goto failed;
@ -6596,7 +6596,7 @@ remoteDomainOpenGraphics(virDomainPtr dom,
remote_domain_open_graphics_args args;
struct private_data *priv = dom->conn->privateData;
int fdin[] = { fd };
size_t fdinlen = ARRAY_CARDINALITY(fdin);
size_t fdinlen = G_N_ELEMENTS(fdin);
remoteDriverLock(priv);

View File

@ -1292,7 +1292,7 @@ elsif ($mode eq "server") {
print "{ $comment\n ${name},\n $arglen,\n (xdrproc_t)$argfilter,\n $retlen,\n (xdrproc_t)$retfilter,\n true,\n $priority\n},\n";
}
print "};\n";
print "size_t ${structprefix}NProcs = ARRAY_CARDINALITY(${structprefix}Procs);\n";
print "size_t ${structprefix}NProcs = G_N_ELEMENTS(${structprefix}Procs);\n";
}
# Bodies for client functions ("remote_client_bodies.h").

View File

@ -368,7 +368,7 @@ virNetClientFindDefaultSshKey(const char *homedir, char **retPath)
const char *keys[] = { "identity", "id_dsa", "id_ecdsa", "id_ed25519", "id_rsa" };
for (i = 0; i < ARRAY_CARDINALITY(keys); ++i) {
for (i = 0; i < G_N_ELEMENTS(keys); ++i) {
int ret = virNetClientCheckKeyExists(homedir, keys[i], retPath);
if (ret != 0)
return ret;
@ -939,7 +939,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
repoll:
ret = poll(fds, ARRAY_CARDINALITY(fds), -1);
ret = poll(fds, G_N_ELEMENTS(fds), -1);
if (ret < 0 && (errno == EAGAIN || errno == EINTR))
goto repoll;
@ -963,7 +963,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
repoll2:
ret = poll(fds, ARRAY_CARDINALITY(fds), -1);
ret = poll(fds, G_N_ELEMENTS(fds), -1);
if (ret < 0 && (errno == EAGAIN || errno == EINTR))
goto repoll2;
@ -1682,7 +1682,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
repoll:
ret = poll(fds, ARRAY_CARDINALITY(fds), timeout);
ret = poll(fds, G_N_ELEMENTS(fds), timeout);
if (ret < 0 && (errno == EAGAIN || errno == EINTR))
goto repoll;

View File

@ -1073,7 +1073,7 @@ virSecurityDACMoveImageMetadataHelper(pid_t pid G_GNUC_UNUSED,
virSecurityManagerMetadataLockStatePtr state;
int ret;
if (!(state = virSecurityManagerMetadataLock(data->mgr, paths, ARRAY_CARDINALITY(paths))))
if (!(state = virSecurityManagerMetadataLock(data->mgr, paths, G_N_ELEMENTS(paths))))
return -1;
ret = virSecurityMoveRememberedLabel(SECURITY_DAC_NAME, data->src, data->dst);

View File

@ -53,7 +53,7 @@ virSecurityDriverPtr virSecurityDriverLookup(const char *name,
VIR_DEBUG("name=%s", NULLSTR(name));
for (i = 0; i < ARRAY_CARDINALITY(security_drivers) && !drv; i++) {
for (i = 0; i < G_N_ELEMENTS(security_drivers) && !drv; i++) {
virSecurityDriverPtr tmp = security_drivers[i];
if (name &&

View File

@ -1974,7 +1974,7 @@ virSecuritySELinuxMoveImageMetadataHelper(pid_t pid G_GNUC_UNUSED,
virSecurityManagerMetadataLockStatePtr state;
int ret;
if (!(state = virSecurityManagerMetadataLock(data->mgr, paths, ARRAY_CARDINALITY(paths))))
if (!(state = virSecurityManagerMetadataLock(data->mgr, paths, G_N_ELEMENTS(paths))))
return -1;
ret = virSecurityMoveRememberedLabel(SECURITY_SELINUX_NAME, data->src, data->dst);

View File

@ -519,9 +519,9 @@ valid_path(const char *path, const bool readonly)
"/etc/libvirt-sandbox/services/" /* for virt-sandbox service config */
};
const int nropaths = ARRAY_CARDINALITY(restricted);
const int nrwpaths = ARRAY_CARDINALITY(restricted_rw);
const int nopaths = ARRAY_CARDINALITY(override);
const int nropaths = G_N_ELEMENTS(restricted);
const int nrwpaths = G_N_ELEMENTS(restricted_rw);
const int nopaths = G_N_ELEMENTS(override);
if (path == NULL) {
vah_error(NULL, 0, _("bad pathname"));

View File

@ -332,7 +332,7 @@ testBuildCapabilities(virConnectPtr conn)
goto error;
}
for (i = 0; i < ARRAY_CARDINALITY(guest_types); i++) {
for (i = 0; i < G_N_ELEMENTS(guest_types); i++) {
if ((guest = virCapabilitiesAddGuest(caps,
guest_types[i],
VIR_ARCH_I686,

View File

@ -81,7 +81,7 @@ static const struct virArchData {
{ "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN },
};
verify(ARRAY_CARDINALITY(virArchData) == VIR_ARCH_LAST);
verify(G_N_ELEMENTS(virArchData) == VIR_ARCH_LAST);
/**

View File

@ -133,7 +133,7 @@ void virAuditSend(virLogSourcePtr source,
[VIR_AUDIT_RECORD_RESOURCE] = AUDIT_VIRT_RESOURCE,
};
if (type >= ARRAY_CARDINALITY(record_types) || record_types[type] == 0)
if (type >= G_N_ELEMENTS(record_types) || record_types[type] == 0)
VIR_WARN("Unknown audit record type %d", type);
else if (audit_log_user_message(auditfd, record_types[type], str, NULL,
clientaddr, clienttty, success) < 0) {

View File

@ -555,7 +555,7 @@ virCgroupV1CpuSetInherit(virCgroupPtr parent,
};
VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path);
for (i = 0; i < ARRAY_CARDINALITY(inherit_values); i++) {
for (i = 0; i < G_N_ELEMENTS(inherit_values); i++) {
VIR_AUTOFREE(char *) value = NULL;
if (virCgroupGetValueStr(parent,
@ -1065,7 +1065,7 @@ virCgroupV1GetBlkioIoServiced(virCgroupPtr group,
return -1;
/* sum up all entries of the same kind, from all devices */
for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
for (i = 0; i < G_N_ELEMENTS(value_names); i++) {
p1 = str1;
p2 = str2;
@ -1171,7 +1171,7 @@ virCgroupV1GetBlkioIoDeviceServiced(virCgroupPtr group,
return -1;
}
for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
for (i = 0; i < G_N_ELEMENTS(value_names); i++) {
if (!(p1 = strstr(p1, value_names[i]))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot find byte %sstats for block device '%s'"),

View File

@ -730,7 +730,7 @@ virCgroupV2GetBlkioIoServiced(virCgroupPtr group,
}
/* sum up all entries of the same kind, from all devices */
for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
for (i = 0; i < G_N_ELEMENTS(value_names); i++) {
p1 = str1;
while ((p1 = strstr(p1, value_names[i]))) {
@ -799,7 +799,7 @@ virCgroupV2GetBlkioIoDeviceServiced(virCgroupPtr group,
return -1;
}
for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
for (i = 0; i < G_N_ELEMENTS(value_names); i++) {
if (!(p1 = strstr(p1, value_names[i]))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot find byte '%s' stats for block device '%s'"),

View File

@ -47,7 +47,7 @@ struct virHashInfo {
};
verify(ARRAY_CARDINALITY(hashinfo) == VIR_CRYPTO_HASH_LAST);
verify(G_N_ELEMENTS(hashinfo) == VIR_CRYPTO_HASH_LAST);
ssize_t
virCryptoHashBuf(virCryptoHash hash,

View File

@ -305,7 +305,7 @@ static const char virDBusBasicTypes[] = {
static bool virDBusIsBasicType(char c)
{
return !!memchr(virDBusBasicTypes, c, ARRAY_CARDINALITY(virDBusBasicTypes));
return !!memchr(virDBusBasicTypes, c, G_N_ELEMENTS(virDBusBasicTypes));
}
/*

View File

@ -34,15 +34,15 @@ virEnumToString(const char * const *types,
static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
const char *name ## TypeToString(int type) { \
return virEnumToString(name ## TypeList, \
ARRAY_CARDINALITY(name ## TypeList), \
G_N_ELEMENTS(name ## TypeList), \
type); \
} \
int name ## TypeFromString(const char *type) { \
return virEnumFromString(name ## TypeList, \
ARRAY_CARDINALITY(name ## TypeList), \
G_N_ELEMENTS(name ## TypeList), \
type); \
} \
verify(ARRAY_CARDINALITY(name ## TypeList) == lastVal)
verify(G_N_ELEMENTS(name ## TypeList) == lastVal)
#define VIR_ENUM_DECL(name) \
const char *name ## TypeToString(int type); \

View File

@ -178,7 +178,7 @@ virFirewallValidateBackend(virFirewallBackend backend)
};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(commands); i++) {
for (i = 0; i < G_N_ELEMENTS(commands); i++) {
if (!virFileIsExecutable(commands[i])) {
virReportSystemError(errno,
_("direct firewall backend requested, but %s is not available"),

View File

@ -168,7 +168,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
}
param->value = 0;
for (j = 0; j < ARRAY_CARDINALITY(cpu_map[i].idx); j++)
for (j = 0; j < G_N_ELEMENTS(cpu_map[i].idx); j++)
param->value += cpu_times[offset + cpu_map[i].idx[j]] * TICK_TO_NSEC;
}

View File

@ -144,11 +144,11 @@ iptablesSetupPrivateChains(virFirewallLayer layer)
bool changed = false;
iptablesGlobalChainData data[] = {
{ layer, "filter",
filter_chains, ARRAY_CARDINALITY(filter_chains), &changed },
filter_chains, G_N_ELEMENTS(filter_chains), &changed },
{ layer, "nat",
natmangle_chains, ARRAY_CARDINALITY(natmangle_chains), &changed },
natmangle_chains, G_N_ELEMENTS(natmangle_chains), &changed },
{ layer, "mangle",
natmangle_chains, ARRAY_CARDINALITY(natmangle_chains), &changed },
natmangle_chains, G_N_ELEMENTS(natmangle_chains), &changed },
};
size_t i;
@ -156,7 +156,7 @@ iptablesSetupPrivateChains(virFirewallLayer layer)
virFirewallStartTransaction(fw, 0);
for (i = 0; i < ARRAY_CARDINALITY(data); i++)
for (i = 0; i < G_N_ELEMENTS(data); i++)
virFirewallAddRuleFull(fw, data[i].layer,
false, iptablesPrivateChainCreate,
&(data[i]), "--table", data[i].table,

View File

@ -54,19 +54,19 @@ static const unsigned short *virKeymapValues[VIR_KEYCODE_SET_LAST] = {
[VIR_KEYCODE_SET_QNUM] = virKeyCodeTable_qnum,
};
#define VIR_KEYMAP_ENTRY_MAX ARRAY_CARDINALITY(virKeyCodeTable_linux)
#define VIR_KEYMAP_ENTRY_MAX G_N_ELEMENTS(virKeyCodeTable_linux)
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_atset1));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_atset2));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_atset3));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_osx));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_xtkbd));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_usb));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_win32));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyCodeTable_qnum));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyNameTable_linux));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyNameTable_osx));
verify(VIR_KEYMAP_ENTRY_MAX == ARRAY_CARDINALITY(virKeyNameTable_win32));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset1));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset2));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset3));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_osx));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_xtkbd));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_usb));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_win32));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_qnum));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_linux));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_osx));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_win32));
VIR_ENUM_IMPL(virKeycodeSet,
VIR_KEYCODE_SET_LAST,

View File

@ -702,7 +702,7 @@ virLogStackTraceToFd(int fd)
const char *msg = "Stack trace not available on this platform\n";
#define STRIP_DEPTH 3
size = backtrace(array, ARRAY_CARDINALITY(array));
size = backtrace(array, G_N_ELEMENTS(array));
if (size) {
backtrace_symbols_fd(array + STRIP_DEPTH, size - STRIP_DEPTH, fd);
ignore_value(safewrite(fd, "\n", 1));
@ -1004,9 +1004,9 @@ virLogOutputToJournald(virLogSourcePtr source,
struct journalState state;
state.iov = iov;
state.iov_end = iov + ARRAY_CARDINALITY(iov);
state.iov_end = iov + G_N_ELEMENTS(iov);
state.bufs = iov_bufs;
state.bufs_end = iov_bufs + ARRAY_CARDINALITY(iov_bufs);
state.bufs_end = iov_bufs + G_N_ELEMENTS(iov_bufs);
journalAddString(&state, "MESSAGE", rawstr);
journalAddInt(&state, "PRIORITY",

View File

@ -3050,7 +3050,7 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
};
# endif
for (i = 0; i < ARRAY_CARDINALITY(ethtool_cmds); i++) {
for (i = 0; i < G_N_ELEMENTS(ethtool_cmds); i++) {
cmd.cmd = ethtool_cmds[i].cmd;
if (virNetDevFeatureAvailable(fd, ifr, &cmd))
ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat));
@ -3059,7 +3059,7 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
# if HAVE_DECL_ETHTOOL_GFLAGS
cmd.cmd = ETHTOOL_GFLAGS;
if (virNetDevFeatureAvailable(fd, ifr, &cmd)) {
for (i = 0; i < ARRAY_CARDINALITY(flags); i++) {
for (i = 0; i < G_N_ELEMENTS(flags); i++) {
if (cmd.data & flags[i].cmd)
ignore_value(virBitmapSetBit(bitmap, flags[i].feat));
}

View File

@ -253,7 +253,7 @@ virNetlinkSendRequest(struct nl_msg *nl_msg, uint32_t src_pid,
fds[0].fd = fd;
fds[0].events = POLLIN;
n = poll(fds, ARRAY_CARDINALITY(fds), NETLINK_ACK_TIMEOUT_S);
n = poll(fds, G_N_ELEMENTS(fds), NETLINK_ACK_TIMEOUT_S);
if (n <= 0) {
if (n < 0)
virReportSystemError(errno, "%s",

View File

@ -168,7 +168,7 @@ static struct virPerfEventAttr attrs[] = {
.attrConfig = PERF_COUNT_SW_EMULATION_FAULTS
},
};
verify(ARRAY_CARDINALITY(attrs) == VIR_PERF_EVENT_LAST);
verify(G_N_ELEMENTS(attrs) == VIR_PERF_EVENT_LAST);
typedef struct virPerfEventAttr *virPerfEventAttrPtr;

View File

@ -628,7 +628,7 @@ int virProcessGetNamespaces(pid_t pid,
*nfdlist = 0;
*fdlist = NULL;
for (i = 0; i < ARRAY_CARDINALITY(ns); i++) {
for (i = 0; i < G_N_ELEMENTS(ns); i++) {
int fd;
VIR_AUTOFREE(char *) nsfile = NULL;

View File

@ -387,7 +387,7 @@ static struct FileTypeInfo const fileTypeInfo[] = {
4+4+4, 8, 512, NULL, vmdk4GetBackingStore, NULL
},
};
verify(ARRAY_CARDINALITY(fileTypeInfo) == VIR_STORAGE_FILE_LAST);
verify(G_N_ELEMENTS(fileTypeInfo) == VIR_STORAGE_FILE_LAST);
/* qcow2 compatible features in the order they appear on-disk */
@ -401,7 +401,7 @@ enum qcow2CompatibleFeature {
static const int qcow2CompatibleFeatureArray[] = {
VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS,
};
verify(ARRAY_CARDINALITY(qcow2CompatibleFeatureArray) ==
verify(G_N_ELEMENTS(qcow2CompatibleFeatureArray) ==
QCOW2_COMPATIBLE_FEATURE_LAST);
static int
@ -3640,7 +3640,7 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
return -1;
}
for (i = 0; i < ARRAY_CARDINALITY(jsonParsers); i++) {
for (i = 0; i < G_N_ELEMENTS(jsonParsers); i++) {
if (STREQ(drvname, jsonParsers[i].drvname))
return jsonParsers[i].func(src, file, jsonParsers[i].opaque);
}

View File

@ -64,7 +64,7 @@ virTPMCreateCancelPath(const char *devpath)
dev = strrchr(devpath, '/');
if (dev) {
dev++;
for (i = 0; i < ARRAY_CARDINALITY(prefix); i++) {
for (i = 0; i < G_N_ELEMENTS(prefix); i++) {
if (virAsprintf(&path, "/sys/class/%s%s/device/cancel",
prefix[i], dev) < 0)
goto cleanup;
@ -290,7 +290,7 @@ virTPMEmulatorInit(void)
virMutexLock(&swtpm_tools_lock);
for (i = 0; i < ARRAY_CARDINALITY(prgs); i++) {
for (i = 0; i < G_N_ELEMENTS(prgs); i++) {
VIR_AUTOFREE(char *) path = NULL;
bool findit = *prgs[i].path == NULL;
struct stat statbuf;

View File

@ -386,7 +386,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd", "ubd"};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) {
for (i = 0; i < G_N_ELEMENTS(drive_prefix); i++) {
if (STRPREFIX(name, drive_prefix[i])) {
ptr = name + strlen(drive_prefix[i]);
break;
@ -1108,7 +1108,7 @@ virGetWin32DirectoryRoot(char **path)
*path = NULL;
if (GetWindowsDirectory(windowsdir, ARRAY_CARDINALITY(windowsdir))) {
if (GetWindowsDirectory(windowsdir, G_N_ELEMENTS(windowsdir))) {
const char *tmp;
/* Usually X:\Windows, but in terminal server environments
* might be an UNC path, AFAIK.

View File

@ -205,7 +205,7 @@ VBoxCGlueInit(unsigned int *version)
}
/* Try the known locations. */
for (i = 0; i < ARRAY_CARDINALITY(knownDirs); ++i) {
for (i = 0; i < G_N_ELEMENTS(knownDirs); ++i) {
if (tryLoadOne(knownDirs[i], true, true, version) >= 0)
return 0;
}

View File

@ -182,7 +182,7 @@ vmwareConnectOpen(virConnectPtr conn,
* the VMware hypervisor. We look this up first since we use it
* for auto detection of the backend
*/
for (i = 0; i < ARRAY_CARDINALITY(vmrun_candidates); i++) {
for (i = 0; i < G_N_ELEMENTS(vmrun_candidates); i++) {
vmrun = virFindFileInPath(vmrun_candidates[i]);
if (vmrun == NULL)
continue;

View File

@ -122,11 +122,11 @@ vzBuildCapabilities(void)
if (virCapabilitiesInitCaches(caps) < 0)
goto error;
verify(ARRAY_CARDINALITY(archs) == ARRAY_CARDINALITY(emulators));
verify(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators));
for (i = 0; i < ARRAY_CARDINALITY(ostypes); i++)
for (j = 0; j < ARRAY_CARDINALITY(archs); j++)
for (k = 0; k < ARRAY_CARDINALITY(emulators); k++)
for (i = 0; i < G_N_ELEMENTS(ostypes); i++)
for (j = 0; j < G_N_ELEMENTS(archs); j++)
for (k = 0; k < G_N_ELEMENTS(emulators); k++)
if (vzCapsAddGuestDomain(caps, ostypes[i], archs[j],
emulators[k], virt_types[k]) < 0)
goto error;

View File

@ -219,7 +219,7 @@ int main(int argc, char **argv) {
ret = EXIT_SUCCESS;
cleanup:
for (i = 0; i < ARRAY_CARDINALITY(buffers); i++)
for (i = 0; i < G_N_ELEMENTS(buffers); i++)
free(buffers[i]);
fclose(log);
free(newenv);

View File

@ -41,7 +41,7 @@ testParseDatastorePath(const void *data G_GNUC_UNUSED)
char *directoryName = NULL;
char *directoryAndFileName = NULL;
for (i = 0; i < ARRAY_CARDINALITY(paths); ++i) {
for (i = 0; i < G_N_ELEMENTS(paths); ++i) {
VIR_FREE(datastoreName);
VIR_FREE(directoryName);
VIR_FREE(directoryAndFileName);
@ -127,7 +127,7 @@ testConvertDateTimeToCalendarTime(const void *data G_GNUC_UNUSED)
esxVI_DateTime dateTime;
long long calendarTime;
for (i = 0; i < ARRAY_CARDINALITY(times); ++i) {
for (i = 0; i < G_N_ELEMENTS(times); ++i) {
dateTime.value = (char *)times[i].dateTime;
if (esxVI_DateTime_ConvertToCalendarTime(&dateTime,
@ -177,7 +177,7 @@ testEscapeDatastoreItem(const void *data G_GNUC_UNUSED)
size_t i;
char *escaped = NULL;
for (i = 0; i < ARRAY_CARDINALITY(datastoreItems); ++i) {
for (i = 0; i < G_N_ELEMENTS(datastoreItems); ++i) {
VIR_FREE(escaped);
escaped = esxUtil_EscapeDatastoreItem(datastoreItems[i].string);
@ -217,7 +217,7 @@ testConvertWindows1252ToUTF8(const void *data G_GNUC_UNUSED)
size_t i;
char *utf8 = NULL;
for (i = 0; i < ARRAY_CARDINALITY(windows1252ToUTF8); ++i) {
for (i = 0; i < G_N_ELEMENTS(windows1252ToUTF8); ++i) {
VIR_FREE(utf8);
utf8 = virVMXConvertToUTF8("Windows-1252",

View File

@ -313,7 +313,7 @@ static void testRemoveCommonRules(char *rules)
size_t i;
char *offset = rules;
for (i = 0; i < ARRAY_CARDINALITY(commonRules); i++) {
for (i = 0; i < G_N_ELEMENTS(commonRules); i++) {
char *tmp = strstr(offset, commonRules[i]);
size_t len = strlen(commonRules[i]);
if (tmp) {

View File

@ -43,7 +43,7 @@ testReadConfigParam(const void *data G_GNUC_UNUSED)
if (virAsprintf(&conf, "%s/openvzutilstest.conf", abs_srcdir) < 0)
return -1;
for (i = 0; i < ARRAY_CARDINALITY(configParams); ++i) {
for (i = 0; i < G_N_ELEMENTS(configParams); ++i) {
if (openvzReadConfigParam(conf, configParams[i].param,
&value) != configParams[i].ret) {
goto cleanup;

View File

@ -68,7 +68,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED)
PREFIX "/share/qemu/firmware/61-ovmf.json",
PREFIX "/share/qemu/firmware/70-aavmf.json",
};
const size_t nexpected = ARRAY_CARDINALITY(expected);
const size_t nexpected = G_N_ELEMENTS(expected);
if (VIR_STRDUP(fakehome, abs_srcdir "/qemufirmwaredata/home/user/.config") < 0)
return -1;
@ -236,7 +236,7 @@ mymain(void)
do { \
unsigned int interfaces[] = {__VA_ARGS__}; \
struct supportedData data = {machine, arch, secure, fwlist, \
interfaces, ARRAY_CARDINALITY(interfaces)}; \
interfaces, G_N_ELEMENTS(interfaces)}; \
if (virTestRun("QEMU FW SUPPORTED " machine " " #arch, \
testSupportedFW, &data) < 0) \
ret = -1; \

View File

@ -2320,7 +2320,7 @@ testQemuMonitorJSONqemuMonitorJSONSendKey(const void *opaque)
return -1;
if (qemuMonitorJSONSendKey(qemuMonitorTestGetMonitor(test),
0, keycodes, ARRAY_CARDINALITY(keycodes)) < 0)
0, keycodes, G_N_ELEMENTS(keycodes)) < 0)
return -1;
return 0;
@ -2349,7 +2349,7 @@ testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *opaque)
if (qemuMonitorJSONSendKey(qemuMonitorTestGetMonitor(test),
31337, keycodes,
ARRAY_CARDINALITY(keycodes)) < 0)
G_N_ELEMENTS(keycodes)) < 0)
return -1;
return 0;

View File

@ -66,7 +66,7 @@ testVUPrecedence(const void *opaque G_GNUC_UNUSED)
SYSCONFDIR "/qemu/vhost-user/40-gpu.json",
PREFIX "/share/qemu/vhost-user/60-gpu.json",
};
const size_t nexpected = ARRAY_CARDINALITY(expected);
const size_t nexpected = G_N_ELEMENTS(expected);
if (VIR_STRDUP(fakehome, abs_srcdir "/qemuvhostuserdata/home/user/.config") < 0)
return -1;

View File

@ -214,7 +214,7 @@ virCommandPassFD(virCommandPtr cmd,
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(testCommandPassSafeFDs); i++) {
for (i = 0; i < G_N_ELEMENTS(testCommandPassSafeFDs); i++) {
if (testCommandPassSafeFDs[i] == fd) {
if (!real_virCommandPassFD)
VIR_MOCK_REAL_INIT(virCommandPassFD);

View File

@ -316,43 +316,43 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
if (ARCH_IS_X86(arch)) {
if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, x86Models,
ARRAY_CARDINALITY(x86Models),
G_N_ELEMENTS(x86Models),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, x86Models,
ARRAY_CARDINALITY(x86Models),
G_N_ELEMENTS(x86Models),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
return -1;
if (!skipLegacy) {
if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM,
x86LegacyModels,
ARRAY_CARDINALITY(x86LegacyModels),
G_N_ELEMENTS(x86LegacyModels),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU,
x86LegacyModels,
ARRAY_CARDINALITY(x86LegacyModels),
G_N_ELEMENTS(x86LegacyModels),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
return -1;
}
} else if (ARCH_IS_ARM(arch)) {
if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, armModels,
ARRAY_CARDINALITY(armModels),
G_N_ELEMENTS(armModels),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, armModels,
ARRAY_CARDINALITY(armModels),
G_N_ELEMENTS(armModels),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
return -1;
} else if (ARCH_IS_PPC64(arch)) {
if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, ppc64Models,
ARRAY_CARDINALITY(ppc64Models),
G_N_ELEMENTS(ppc64Models),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, ppc64Models,
ARRAY_CARDINALITY(ppc64Models),
G_N_ELEMENTS(ppc64Models),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
return -1;
} else if (ARCH_IS_S390(arch)) {
if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, s390xModels,
ARRAY_CARDINALITY(s390xModels),
G_N_ELEMENTS(s390xModels),
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
return -1;
}

View File

@ -1193,7 +1193,7 @@ virTestCounterReset(const char *prefix)
const char
*virTestCounterNext(void)
{
size_t len = ARRAY_CARDINALITY(virtTestCounterStr);
size_t len = G_N_ELEMENTS(virtTestCounterStr);
/* calculate length of the rest of the string */
len -= (virtTestCounterPrefixEndOffset - virtTestCounterStr);

View File

@ -43,8 +43,8 @@ static virCPUDef cpuDefaultData = {
.sockets = 1,
.cores = 2,
.threads = 1,
.nfeatures = ARRAY_CARDINALITY(cpuDefaultFeatures),
.nfeatures_max = ARRAY_CARDINALITY(cpuDefaultFeatures),
.nfeatures = G_N_ELEMENTS(cpuDefaultFeatures),
.nfeatures_max = G_N_ELEMENTS(cpuDefaultFeatures),
.features = cpuDefaultFeatures,
};
@ -82,8 +82,8 @@ static virCPUDef cpuHaswellData = {
.sockets = 1,
.cores = 2,
.threads = 2,
.nfeatures = ARRAY_CARDINALITY(cpuHaswellFeatures),
.nfeatures_max = ARRAY_CARDINALITY(cpuHaswellFeatures),
.nfeatures = G_N_ELEMENTS(cpuHaswellFeatures),
.nfeatures_max = G_N_ELEMENTS(cpuHaswellFeatures),
.features = cpuHaswellFeatures,
};

View File

@ -53,11 +53,11 @@ static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
};
machines = virCapabilitiesAllocMachines(x86_machines,
ARRAY_CARDINALITY(x86_machines));
G_N_ELEMENTS(x86_machines));
if (machines == NULL)
return NULL;
*nmachines = ARRAY_CARDINALITY(x86_machines);
*nmachines = G_N_ELEMENTS(x86_machines);
return machines;
}
@ -78,7 +78,7 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
return NULL;
machines = virCapabilitiesAllocMachines(x86_machines,
ARRAY_CARDINALITY(x86_machines));
G_N_ELEMENTS(x86_machines));
if (machines == NULL) {
VIR_FREE(canonical);
return NULL;
@ -86,7 +86,7 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
machines[1]->canonical = canonical;
*nmachines = ARRAY_CARDINALITY(x86_machines);
*nmachines = G_N_ELEMENTS(x86_machines);
return machines;
}
@ -304,7 +304,7 @@ static int testQemuAddRISCV32Guest(virCapsPtr caps)
"sifive_e",
"virt",
"sifive_u" };
static const int nmachines = ARRAY_CARDINALITY(names);
static const int nmachines = G_N_ELEMENTS(names);
virCapsGuestMachinePtr *machines = NULL;
virCapsGuestPtr guest;
@ -335,7 +335,7 @@ static int testQemuAddRISCV64Guest(virCapsPtr caps)
"sifive_e",
"virt",
"sifive_u" };
static const int nmachines = ARRAY_CARDINALITY(names);
static const int nmachines = G_N_ELEMENTS(names);
virCapsGuestMachinePtr *machines = NULL;
virCapsGuestPtr guest;
@ -367,14 +367,14 @@ static int testQemuAddS390Guest(virCapsPtr caps)
virCapsGuestPtr guest;
machines = virCapabilitiesAllocMachines(s390_machines,
ARRAY_CARDINALITY(s390_machines));
G_N_ELEMENTS(s390_machines));
if (!machines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X,
QEMUBinList[TEST_UTILS_QEMU_BIN_S390X],
NULL,
ARRAY_CARDINALITY(s390_machines),
G_N_ELEMENTS(s390_machines),
machines);
if (!guest)
goto error;
@ -388,7 +388,7 @@ static int testQemuAddS390Guest(virCapsPtr caps)
return 0;
error:
virCapabilitiesFreeMachines(machines, ARRAY_CARDINALITY(s390_machines));
virCapabilitiesFreeMachines(machines, G_N_ELEMENTS(s390_machines));
return -1;
}
@ -399,14 +399,14 @@ static int testQemuAddArm6Guest(virCapsPtr caps)
virCapsGuestPtr guest;
capsmachines = virCapabilitiesAllocMachines(machines,
ARRAY_CARDINALITY(machines));
G_N_ELEMENTS(machines));
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_ARMV6L,
QEMUBinList[TEST_UTILS_QEMU_BIN_ARM],
NULL,
ARRAY_CARDINALITY(machines),
G_N_ELEMENTS(machines),
capsmachines);
if (!guest)
goto error;
@ -420,7 +420,7 @@ static int testQemuAddArm6Guest(virCapsPtr caps)
return 0;
error:
virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines));
virCapabilitiesFreeMachines(capsmachines, G_N_ELEMENTS(machines));
return -1;
}
@ -433,14 +433,14 @@ static int testQemuAddArm7Guest(virCapsPtr caps)
virCapsGuestPtr guest;
capsmachines = virCapabilitiesAllocMachines(machines,
ARRAY_CARDINALITY(machines));
G_N_ELEMENTS(machines));
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_ARMV7L,
QEMUBinList[TEST_UTILS_QEMU_BIN_ARM],
NULL,
ARRAY_CARDINALITY(machines),
G_N_ELEMENTS(machines),
capsmachines);
if (!guest)
goto error;
@ -454,7 +454,7 @@ static int testQemuAddArm7Guest(virCapsPtr caps)
return 0;
error:
virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines));
virCapabilitiesFreeMachines(capsmachines, G_N_ELEMENTS(machines));
return -1;
}
@ -465,14 +465,14 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps)
virCapsGuestPtr guest;
capsmachines = virCapabilitiesAllocMachines(machines,
ARRAY_CARDINALITY(machines));
G_N_ELEMENTS(machines));
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_AARCH64,
QEMUBinList[TEST_UTILS_QEMU_BIN_AARCH64],
NULL,
ARRAY_CARDINALITY(machines),
G_N_ELEMENTS(machines),
capsmachines);
if (!guest)
goto error;
@ -486,7 +486,7 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps)
return 0;
error:
virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines));
virCapabilitiesFreeMachines(capsmachines, G_N_ELEMENTS(machines));
return -1;
}
@ -669,7 +669,7 @@ int qemuTestCapsCacheInsert(virFileCachePtr cache,
return -ENOMEM;
}
for (i = 0; i < ARRAY_CARDINALITY(QEMUBinList); i++) {
for (i = 0; i < G_N_ELEMENTS(QEMUBinList); i++) {
virObjectRef(tmpCaps);
if (virFileCacheInsertData(cache, QEMUBinList[i], tmpCaps) < 0) {
virObjectUnref(tmpCaps);
@ -884,7 +884,7 @@ testQemuGetLatestCaps(void)
VIR_TEST_VERBOSE("");
for (i = 0; i < ARRAY_CARDINALITY(archs); ++i) {
for (i = 0; i < G_N_ELEMENTS(archs); ++i) {
char *cap = testQemuGetLatestCapsForArch(archs[i], "xml");
if (!cap || virHashAddEntry(capslatest, archs[i], cap) < 0)

View File

@ -29,7 +29,7 @@ testXLInitCaps(void)
caps->host.cpu = virCPUDefCopy(&cpuDefaultData);
nmachines = ARRAY_CARDINALITY(x86_machines);
nmachines = G_N_ELEMENTS(x86_machines);
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
@ -42,7 +42,7 @@ testXLInitCaps(void)
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
NULL, 0, NULL) == NULL)
goto cleanup;
nmachines = ARRAY_CARDINALITY(xen_machines);
nmachines = G_N_ELEMENTS(xen_machines);
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
goto cleanup;
@ -57,7 +57,7 @@ testXLInitCaps(void)
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
NULL, 0, NULL) == NULL)
goto cleanup;
nmachines = ARRAY_CARDINALITY(pvh_machines);
nmachines = G_N_ELEMENTS(pvh_machines);
if ((machines = virCapabilitiesAllocMachines(pvh_machines, nmachines)) == NULL)
goto cleanup;

View File

@ -44,7 +44,7 @@ testIndexToDiskName(const void *data G_GNUC_UNUSED)
size_t i;
char *diskName = NULL;
for (i = 0; i < ARRAY_CARDINALITY(diskNames); ++i) {
for (i = 0; i < G_N_ELEMENTS(diskNames); ++i) {
VIR_FREE(diskName);
diskName = virIndexToDiskName(i, "sd");
@ -102,7 +102,7 @@ testDiskNameParse(const void *data G_GNUC_UNUSED)
int partition;
struct testDiskName *disk = NULL;
for (i = 0; i < ARRAY_CARDINALITY(diskNamesPart); ++i) {
for (i = 0; i < G_N_ELEMENTS(diskNamesPart); ++i) {
disk = &diskNamesPart[i];
if (virDiskNameParse(disk->name, &idx, &partition))
return -1;
@ -120,7 +120,7 @@ testDiskNameParse(const void *data G_GNUC_UNUSED)
}
}
for (i = 0; i < ARRAY_CARDINALITY(diskNamesInvalid); ++i) {
for (i = 0; i < G_N_ELEMENTS(diskNamesInvalid); ++i) {
if (!virDiskNameParse(diskNamesInvalid[i], &idx, &partition)) {
VIR_TEST_DEBUG("Should Fail [%s]", diskNamesInvalid[i]);
return -1;
@ -161,7 +161,7 @@ testParseVersionString(const void *data G_GNUC_UNUSED)
size_t i;
unsigned long version;
for (i = 0; i < ARRAY_CARDINALITY(versions); ++i) {
for (i = 0; i < G_N_ELEMENTS(versions); ++i) {
result = virParseVersionString(versions[i].string, &version,
versions[i].allowMissing);
@ -210,7 +210,7 @@ testRoundValueToPowerOfTwo(const void *data G_GNUC_UNUSED)
unsigned int result;
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(roundData); i++) {
for (i = 0; i < G_N_ELEMENTS(roundData); i++) {
result = VIR_ROUND_UP_POWER_OF_TWO(roundData[i].input);
if (roundData[i].output != result) {
VIR_TEST_DEBUG("\nInput number [%u]", roundData[i].input);

View File

@ -188,7 +188,7 @@ test4(const void *data G_GNUC_UNUSED)
virBitmapPtr bitmap = NULL;
ssize_t i, j;
if (ARRAY_CARDINALITY(bitsPos) + ARRAY_CARDINALITY(bitsPosInv) != size)
if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) != size)
goto error;
/* 0. empty set */
@ -243,7 +243,7 @@ test4(const void *data G_GNUC_UNUSED)
j = 0;
i = -1;
while (j < ARRAY_CARDINALITY(bitsPos)) {
while (j < G_N_ELEMENTS(bitsPos)) {
i = virBitmapNextSetBit(bitmap, i);
if (i != bitsPos[j++])
goto error;
@ -260,7 +260,7 @@ test4(const void *data G_GNUC_UNUSED)
j = 0;
i = -1;
while (j < ARRAY_CARDINALITY(bitsPosInv)) {
while (j < G_N_ELEMENTS(bitsPosInv)) {
i = virBitmapNextClearBit(bitmap, i);
if (i != bitsPosInv[j++])
goto error;
@ -680,7 +680,7 @@ test13(const void *opaque G_GNUC_UNUSED)
size_t i = 0;
int ret = -1;
for (i = 0; i < ARRAY_CARDINALITY(strings); i++) {
for (i = 0; i < G_N_ELEMENTS(strings); i++) {
map = virBitmapNewString(strings[i]);
str = virBitmapToString(map, false, true);

View File

@ -825,7 +825,7 @@ testCgroupGetMemoryStat(const void *args G_GNUC_UNUSED)
"inactive_file",
"unevictable"
};
unsigned long long values[ARRAY_CARDINALITY(expected_values)];
unsigned long long values[G_N_ELEMENTS(expected_values)];
if ((rv = virCgroupNewPartition("/virtualmachines", true,
(1 << VIR_CGROUP_CONTROLLER_MEMORY),
@ -842,7 +842,7 @@ testCgroupGetMemoryStat(const void *args G_GNUC_UNUSED)
goto cleanup;
}
for (i = 0; i < ARRAY_CARDINALITY(expected_values); i++) {
for (i = 0; i < G_N_ELEMENTS(expected_values); i++) {
/* NB: virCgroupGetMemoryStat returns a KiB scaled value */
if ((expected_values[i] >> 10) != values[i]) {
fprintf(stderr,
@ -879,7 +879,7 @@ static int testCgroupGetBlkioIoServiced(const void *args G_GNUC_UNUSED)
"requests read",
"requests written"
};
long long values[ARRAY_CARDINALITY(expected_values)];
long long values[G_N_ELEMENTS(expected_values)];
if ((rv = virCgroupNewPartition("/virtualmachines", true,
(1 << VIR_CGROUP_CONTROLLER_BLKIO),
@ -895,7 +895,7 @@ static int testCgroupGetBlkioIoServiced(const void *args G_GNUC_UNUSED)
goto cleanup;
}
for (i = 0; i < ARRAY_CARDINALITY(expected_values); i++) {
for (i = 0; i < G_N_ELEMENTS(expected_values); i++) {
if (expected_values[i] != values[i]) {
fprintf(stderr,
"Wrong value for %s from virCgroupBlkioIoServiced (expected %lld)\n",
@ -934,7 +934,7 @@ static int testCgroupGetBlkioIoDeviceServiced(const void *args G_GNUC_UNUSED)
"requests read",
"requests written"
};
long long values[ARRAY_CARDINALITY(expected_values0)];
long long values[G_N_ELEMENTS(expected_values0)];
if ((rv = virCgroupNewPartition("/virtualmachines", true,
(1 << VIR_CGROUP_CONTROLLER_BLKIO),
@ -951,7 +951,7 @@ static int testCgroupGetBlkioIoDeviceServiced(const void *args G_GNUC_UNUSED)
goto cleanup;
}
for (i = 0; i < ARRAY_CARDINALITY(expected_values0); i++) {
for (i = 0; i < G_N_ELEMENTS(expected_values0); i++) {
if (expected_values0[i] != values[i]) {
fprintf(stderr,
"Wrong value for %s from virCgroupGetBlkioIoDeviceServiced (expected %lld)\n",
@ -968,7 +968,7 @@ static int testCgroupGetBlkioIoDeviceServiced(const void *args G_GNUC_UNUSED)
goto cleanup;
}
for (i = 0; i < ARRAY_CARDINALITY(expected_values1); i++) {
for (i = 0; i < G_N_ELEMENTS(expected_values1); i++) {
if (expected_values1[i] != values[i]) {
fprintf(stderr,
"Wrong value for %s from virCgroupGetBlkioIoDeviceServiced (expected %lld)\n",

View File

@ -376,7 +376,7 @@ mymain(void)
# define DO_TEST_MOUNT_SUBTREE(name, path, prefix, mounts, rev) \
do { \
struct testFileGetMountSubtreeData data = { \
path, prefix, mounts, ARRAY_CARDINALITY(mounts), rev \
path, prefix, mounts, G_N_ELEMENTS(mounts), rev \
}; \
if (virTestRun(name, testFileGetMountSubtree, &data) < 0) \
ret = -1; \

View File

@ -991,7 +991,7 @@ testFirewallQueryCallback(virFirewallPtr fw,
"--jump", "REJECT", NULL);
for (i = 0; lines[i] != NULL; i++) {
if (expectedLineNum >= ARRAY_CARDINALITY(expectedLines)) {
if (expectedLineNum >= G_N_ELEMENTS(expectedLines)) {
expectedLineError = true;
break;
}

View File

@ -26,7 +26,7 @@ testHashInit(int size)
/* entries are added in reverse order so that they will be linked in
* collision list in the same order as in the uuids array
*/
for (i = ARRAY_CARDINALITY(uuids) - 1; i >= 0; i--) {
for (i = G_N_ELEMENTS(uuids) - 1; i >= 0; i--) {
ssize_t oldsize = virHashTableSize(hash);
if (virHashAddEntry(hash, uuids[i], (void *) uuids[i]) < 0) {
virHashFree(hash);
@ -39,7 +39,7 @@ testHashInit(int size)
}
}
for (i = 0; i < ARRAY_CARDINALITY(uuids); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids); i++) {
if (!virHashLookup(hash, uuids[i])) {
VIR_TEST_VERBOSE("\nentry \"%s\" could not be found", uuids[i]);
virHashFree(hash);
@ -98,7 +98,7 @@ testHashGrow(const void *data)
if (!(hash = testHashInit(info->count)))
return -1;
if (testHashCheckCount(hash, ARRAY_CARDINALITY(uuids)) < 0)
if (testHashCheckCount(hash, G_N_ELEMENTS(uuids)) < 0)
goto cleanup;
ret = 0;
@ -112,7 +112,7 @@ testHashGrow(const void *data)
static int
testHashUpdate(const void *data G_GNUC_UNUSED)
{
int count = ARRAY_CARDINALITY(uuids) + ARRAY_CARDINALITY(uuids_new);
int count = G_N_ELEMENTS(uuids) + G_N_ELEMENTS(uuids_new);
virHashTablePtr hash;
size_t i;
int ret = -1;
@ -120,7 +120,7 @@ testHashUpdate(const void *data G_GNUC_UNUSED)
if (!(hash = testHashInit(0)))
return -1;
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids_subset); i++) {
if (virHashUpdateEntry(hash, uuids_subset[i], (void *) 1) < 0) {
VIR_TEST_VERBOSE("\nentry \"%s\" could not be updated",
uuids_subset[i]);
@ -128,7 +128,7 @@ testHashUpdate(const void *data G_GNUC_UNUSED)
}
}
for (i = 0; i < ARRAY_CARDINALITY(uuids_new); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids_new); i++) {
if (virHashUpdateEntry(hash, uuids_new[i], (void *) 1) < 0) {
VIR_TEST_VERBOSE("\nnew entry \"%s\" could not be updated",
uuids_new[i]);
@ -150,7 +150,7 @@ testHashUpdate(const void *data G_GNUC_UNUSED)
static int
testHashRemove(const void *data G_GNUC_UNUSED)
{
int count = ARRAY_CARDINALITY(uuids) - ARRAY_CARDINALITY(uuids_subset);
int count = G_N_ELEMENTS(uuids) - G_N_ELEMENTS(uuids_subset);
virHashTablePtr hash;
size_t i;
int ret = -1;
@ -158,7 +158,7 @@ testHashRemove(const void *data G_GNUC_UNUSED)
if (!(hash = testHashInit(0)))
return -1;
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids_subset); i++) {
if (virHashRemoveEntry(hash, uuids_subset[i]) < 0) {
VIR_TEST_VERBOSE("\nentry \"%s\" could not be removed",
uuids_subset[i]);
@ -178,7 +178,7 @@ testHashRemove(const void *data G_GNUC_UNUSED)
const int testHashCountRemoveForEachSome =
ARRAY_CARDINALITY(uuids) - ARRAY_CARDINALITY(uuids_subset);
G_N_ELEMENTS(uuids) - G_N_ELEMENTS(uuids_subset);
static int
testHashRemoveForEachSome(void *payload G_GNUC_UNUSED,
@ -188,7 +188,7 @@ testHashRemoveForEachSome(void *payload G_GNUC_UNUSED,
virHashTablePtr hash = data;
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids_subset); i++) {
if (STREQ(uuids_subset[i], name)) {
if (virHashRemoveEntry(hash, name) < 0) {
VIR_TEST_VERBOSE("\nentry \"%s\" could not be removed",
@ -244,7 +244,7 @@ testHashRemoveForEach(const void *data)
static int
testHashSteal(const void *data G_GNUC_UNUSED)
{
int count = ARRAY_CARDINALITY(uuids) - ARRAY_CARDINALITY(uuids_subset);
int count = G_N_ELEMENTS(uuids) - G_N_ELEMENTS(uuids_subset);
virHashTablePtr hash;
size_t i;
int ret = -1;
@ -252,7 +252,7 @@ testHashSteal(const void *data G_GNUC_UNUSED)
if (!(hash = testHashInit(0)))
return -1;
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids_subset); i++) {
if (!virHashSteal(hash, uuids_subset[i])) {
VIR_TEST_VERBOSE("\nentry \"%s\" could not be stolen",
uuids_subset[i]);
@ -280,7 +280,7 @@ testHashRemoveSetIter(const void *payload G_GNUC_UNUSED,
bool rem = false;
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
for (i = 0; i < G_N_ELEMENTS(uuids_subset); i++) {
if (STREQ(uuids_subset[i], name)) {
rem = true;
break;
@ -318,7 +318,7 @@ testHashRemoveSet(const void *data G_GNUC_UNUSED)
goto cleanup;
}
if (testHashCheckCount(hash, ARRAY_CARDINALITY(uuids) - count) < 0)
if (testHashCheckCount(hash, G_N_ELEMENTS(uuids) - count) < 0)
goto cleanup;
ret = 0;
@ -329,7 +329,7 @@ testHashRemoveSet(const void *data G_GNUC_UNUSED)
}
const int testSearchIndex = ARRAY_CARDINALITY(uuids_subset) / 2;
const int testSearchIndex = G_N_ELEMENTS(uuids_subset) / 2;
static int
testHashSearchIter(const void *payload G_GNUC_UNUSED,
@ -357,7 +357,7 @@ testHashSearch(const void *data G_GNUC_UNUSED)
goto cleanup;
}
if (testHashCheckCount(hash, ARRAY_CARDINALITY(uuids)) < 0)
if (testHashCheckCount(hash, G_N_ELEMENTS(uuids)) < 0)
goto cleanup;
ret = 0;

View File

@ -260,7 +260,7 @@ mymain(void)
if (virInitialize() < 0)
return EXIT_FAILURE;
for (i = 0; i < ARRAY_CARDINALITY(nodeData); i++)
for (i = 0; i < G_N_ELEMENTS(nodeData); i++)
if (virTestRun(nodeData[i].testName, linuxTestHostCPU, &nodeData[i]) != 0)
ret = -1;

View File

@ -343,7 +343,7 @@ mymain(void)
.fake_cmd_output = "iscsiadm_sendtargets",
.portal = "10.20.30.40:3260,1",
.expected_targets = targets,
.nexpected = ARRAY_CARDINALITY(targets),
.nexpected = G_N_ELEMENTS(targets),
};
if (virTestRun("ISCSI scan targets", testISCSIScanTargets, &infoTargets) < 0)
rv = -1;

View File

@ -61,7 +61,7 @@ static int testMessageHeaderEncode(const void *args G_GNUC_UNUSED)
if (virNetMessageEncodeHeader(msg) < 0)
goto cleanup;
if (ARRAY_CARDINALITY(expect) != msg->bufferOffset) {
if (G_N_ELEMENTS(expect) != msg->bufferOffset) {
VIR_DEBUG("Expect message offset %zu got %zu",
sizeof(expect), msg->bufferOffset);
goto cleanup;
@ -253,7 +253,7 @@ static int testMessagePayloadEncode(const void *args G_GNUC_UNUSED)
if (virNetMessageEncodePayload(msg, (xdrproc_t)xdr_virNetMessageError, &err) < 0)
goto cleanup;
if (ARRAY_CARDINALITY(expect) != msg->bufferLength) {
if (G_N_ELEMENTS(expect) != msg->bufferLength) {
VIR_DEBUG("Expect message length %zu got %zu",
sizeof(expect), msg->bufferLength);
goto cleanup;
@ -495,7 +495,7 @@ static int testMessagePayloadStreamEncode(const void *args G_GNUC_UNUSED)
if (virNetMessageEncodePayloadRaw(msg, stream, strlen(stream)) < 0)
goto cleanup;
if (ARRAY_CARDINALITY(expect) != msg->bufferLength) {
if (G_N_ELEMENTS(expect) != msg->bufferLength) {
VIR_DEBUG("Expect message length %zu got %zu",
sizeof(expect), msg->bufferLength);
goto cleanup;

View File

@ -562,7 +562,7 @@ mymain(void)
testTLSWriteCertChain("cacertchain-ctx.pem",
certchain,
ARRAY_CARDINALITY(certchain));
G_N_ELEMENTS(certchain));
DO_CTX_TEST(true, "cacertchain-ctx.pem", servercertlevel3areq.filename, false);
DO_CTX_TEST(false, "cacertchain-ctx.pem", clientcertlevel2breq.filename, false);

View File

@ -456,7 +456,7 @@ mymain(void)
testTLSWriteCertChain("cacertchain-sess.pem",
certchain,
ARRAY_CARDINALITY(certchain));
G_N_ELEMENTS(certchain));
DO_SESS_TEST("cacertchain-sess.pem", servercertlevel3areq.filename, clientcertlevel2breq.filename,
false, false, "libvirt.org", NULL);

View File

@ -130,7 +130,7 @@ virNumaGetPages(int node,
size_t *npages)
{
const int pages_def[] = { 4, 2 * 1024, 1 * 1024 * 1024};
const int npages_def = ARRAY_CARDINALITY(pages_def);
const int npages_def = G_N_ELEMENTS(pages_def);
size_t i = 0;
if (pages_size)

View File

@ -91,7 +91,7 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED)
{
int ret = -1;
virPCIDevicePtr dev[] = {NULL, NULL, NULL};
size_t i, nDev = ARRAY_CARDINALITY(dev);
size_t i, nDev = G_N_ELEMENTS(dev);
virPCIDeviceListPtr activeDevs = NULL, inactiveDevs = NULL;
int count;
@ -132,7 +132,7 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED)
{
int ret = -1;
virPCIDevicePtr dev[] = {NULL, NULL, NULL};
size_t i, nDev = ARRAY_CARDINALITY(dev);
size_t i, nDev = G_N_ELEMENTS(dev);
virPCIDeviceListPtr activeDevs = NULL, inactiveDevs = NULL;
int count;
@ -167,7 +167,7 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
{
int ret = -1;
virPCIDevicePtr dev[] = {NULL, NULL, NULL};
size_t i, nDev = ARRAY_CARDINALITY(dev);
size_t i, nDev = G_N_ELEMENTS(dev);
virPCIDeviceListPtr activeDevs = NULL, inactiveDevs = NULL;
int count;

View File

@ -96,7 +96,7 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block,
is_authorized = 0;
is_challenge = 0;
retdetails = retdetailscancelled;
retdetailslen = ARRAY_CARDINALITY(retdetailscancelled) / 2;
retdetailslen = G_N_ELEMENTS(retdetailscancelled) / 2;
} else if (STREQ(actionid, "org.libvirt.test.details")) {
size_t i;
is_authorized = 0;

View File

@ -85,7 +85,7 @@ static int testRotatingFileReaderAssertBufferContent(const char *buf,
char bytes[] = { FILEBYTE, FILEBYTE0, FILEBYTE1 };
size_t total = 0;
if (nregions > ARRAY_CARDINALITY(bytes)) {
if (nregions > G_N_ELEMENTS(bytes)) {
fprintf(stderr, "Too many regions %zu\n", nregions);
return -1;
}
@ -573,7 +573,7 @@ static int testRotatingFileReaderOne(const void *data G_GNUC_UNUSED)
goto cleanup;
if (testRotatingFileReaderAssertBufferContent(buf, got,
ARRAY_CARDINALITY(regions),
G_N_ELEMENTS(regions),
regions) < 0)
goto cleanup;
@ -605,7 +605,7 @@ static int testRotatingFileReaderAll(const void *data G_GNUC_UNUSED)
goto cleanup;
if (testRotatingFileReaderAssertBufferContent(buf, got,
ARRAY_CARDINALITY(regions),
G_N_ELEMENTS(regions),
regions) < 0)
goto cleanup;
@ -637,7 +637,7 @@ static int testRotatingFileReaderPartial(const void *data G_GNUC_UNUSED)
goto cleanup;
if (testRotatingFileReaderAssertBufferContent(buf, got,
ARRAY_CARDINALITY(regions),
G_N_ELEMENTS(regions),
regions) < 0)
goto cleanup;
@ -678,7 +678,7 @@ static int testRotatingFileReaderSeek(const void *data G_GNUC_UNUSED)
goto cleanup;
if (testRotatingFileReaderAssertBufferContent(buf, got,
ARRAY_CARDINALITY(regions),
G_N_ELEMENTS(regions),
regions) < 0)
goto cleanup;

Some files were not shown because too many files have changed in this diff Show More