G_STATIC_ASSERT() is a drop-in functional equivalent of the GNULIB verify() macro. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- build-aux/syntax-check.mk | 6 ------ src/conf/snapshot_conf.h | 2 +- src/conf/virdomaincheckpointobjlist.c | 8 ++++---- src/esx/esx_network_driver.c | 2 +- src/esx/esx_storage_backend_iscsi.c | 2 +- src/esx/esx_storage_backend_vmfs.c | 2 +- src/internal.h | 1 - src/libxl/xen_xm.c | 3 +-- src/nwfilter/nwfilter_dhcpsnoop.c | 4 ++-- src/qemu/qemu_blockjob.h | 4 ++-- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_firmware.h | 2 +- src/qemu/qemu_migration_params.c | 2 +- src/remote/remote_daemon_dispatch.c | 10 +++++----- src/util/virarch.c | 3 +-- src/util/vircgroup.h | 2 +- src/util/vircrypto.c | 2 +- src/util/virenum.h | 8 ++++---- src/util/virinitctl.c | 4 ++-- src/util/virkeycode.c | 22 +++++++++++----------- src/util/virmacaddr.h | 2 +- src/util/virobject.h | 8 ++++---- src/util/virperf.c | 2 +- src/util/virstoragefile.c | 4 ++-- src/util/virtypedparam.h | 2 +- src/util/virutil.c | 3 +-- src/vz/vz_driver.c | 2 +- tests/virstringtest.c | 7 +++---- tools/virsh-domain.c | 2 +- tools/virsh-network.c | 2 +- tools/virsh-nodedev.c | 2 +- tools/virsh-pool.c | 2 +- tools/virsh-secret.c | 2 +- tools/virt-host-validate-common.c | 4 ++-- 35 files changed, 63 insertions(+), 74 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 2bbadd426c..7d5597e028 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1635,12 +1635,6 @@ sc_prohibit_dirent_without_use: re='\<($(_dirent_syms_re))\>' \ $(_sc_header_without_use) -# Prohibit the inclusion of verify.h without an actual use. -sc_prohibit_verify_without_use: - @h='verify.h' \ - re='\<(verify(true|expr)?|assume|static_assert) *\(' \ - $(_sc_header_without_use) - # Don't include xfreopen.h unless you use one of its functions. sc_prohibit_xfreopen_without_use: @h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index c02d0fa263..b5b1ef2718 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -56,7 +56,7 @@ typedef enum { VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT, VIR_DOMAIN_SNAPSHOT_LAST } virDomainSnapshotState; -verify((int)VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT == VIR_DOMAIN_LAST); +G_STATIC_ASSERT((int)VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT == VIR_DOMAIN_LAST); /* Stores disk-snapshot information */ typedef struct _virDomainSnapshotDiskDef virDomainSnapshotDiskDef; diff --git a/src/conf/virdomaincheckpointobjlist.c b/src/conf/virdomaincheckpointobjlist.c index 41181477f4..a4942ea706 100644 --- a/src/conf/virdomaincheckpointobjlist.c +++ b/src/conf/virdomaincheckpointobjlist.c @@ -91,13 +91,13 @@ virDomainCheckpointObjListGetNames(virDomainCheckpointObjListPtr checkpoints, unsigned int flags) { /* We intentionally chose our public flags to match the common flags */ - verify(VIR_DOMAIN_CHECKPOINT_LIST_ROOTS == + G_STATIC_ASSERT(VIR_DOMAIN_CHECKPOINT_LIST_ROOTS == (int) VIR_DOMAIN_MOMENT_LIST_ROOTS); - verify(VIR_DOMAIN_CHECKPOINT_LIST_TOPOLOGICAL == + G_STATIC_ASSERT(VIR_DOMAIN_CHECKPOINT_LIST_TOPOLOGICAL == (int) VIR_DOMAIN_MOMENT_LIST_TOPOLOGICAL); - verify(VIR_DOMAIN_CHECKPOINT_LIST_LEAVES == + G_STATIC_ASSERT(VIR_DOMAIN_CHECKPOINT_LIST_LEAVES == (int) VIR_DOMAIN_MOMENT_LIST_LEAVES); - verify(VIR_DOMAIN_CHECKPOINT_LIST_NO_LEAVES == + G_STATIC_ASSERT(VIR_DOMAIN_CHECKPOINT_LIST_NO_LEAVES == (int) VIR_DOMAIN_MOMENT_LIST_NO_LEAVES); return virDomainMomentObjListGetNames(checkpoints->base, from, names, diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index 4f359c61e2..0d52818e18 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -41,7 +41,7 @@ * The UUID of a network is the MD5 sum of its key. Therefore, verify that * UUID and MD5 sum match in size, because we rely on that. */ -verify(VIR_CRYPTO_HASH_SIZE_MD5 == VIR_UUID_BUFLEN); +G_STATIC_ASSERT(VIR_CRYPTO_HASH_SIZE_MD5 == VIR_UUID_BUFLEN); static int diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c index 72ab0d3cb0..395a347cf3 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -43,7 +43,7 @@ * The UUID of a storage pool is the MD5 sum of its mount path. Therefore, * verify that UUID and MD5 sum match in size, because we rely on that. */ -verify(VIR_CRYPTO_HASH_SIZE_MD5 == VIR_UUID_BUFLEN); +G_STATIC_ASSERT(VIR_CRYPTO_HASH_SIZE_MD5 == VIR_UUID_BUFLEN); diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c index 61b30c3c1d..4f613bf93b 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -49,7 +49,7 @@ VIR_LOG_INIT("esx.esx_storage_backend_vmfs"); * The UUID of a storage pool is the MD5 sum of its mount path. Therefore, * verify that UUID and MD5 sum match in size, because we rely on that. */ -verify(VIR_CRYPTO_HASH_SIZE_MD5 == VIR_UUID_BUFLEN); +G_STATIC_ASSERT(VIR_CRYPTO_HASH_SIZE_MD5 == VIR_UUID_BUFLEN); diff --git a/src/internal.h b/src/internal.h index 686b7cfcc2..dad3cf757c 100644 --- a/src/internal.h +++ b/src/internal.h @@ -22,7 +22,6 @@ #include <errno.h> #include <limits.h> -#include <verify.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 5d5d521c18..54eb6fc97d 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -26,7 +26,6 @@ #include "virerror.h" #include "virconf.h" #include "viralloc.h" -#include "verify.h" #include "xenxs_private.h" #include "xen_xm.h" #include "domain_conf.h" @@ -581,7 +580,7 @@ xenFormatXMInputDevs(virConfPtr conf, virDomainDefPtr def) /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is either 32, or 64 on a platform where long is big enough. */ -verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT); +G_STATIC_ASSERT(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT); /* * Convert a virDomainDef object into an XM config record. diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index f3acaf00dd..629f974177 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -186,7 +186,7 @@ struct _virNWFilterSnoopEthHdr { uint16_t eh_type; uint8_t eh_data[]; } ATTRIBUTE_PACKED; -verify(sizeof(struct _virNWFilterSnoopEthHdr) == 14); +G_STATIC_ASSERT(sizeof(struct _virNWFilterSnoopEthHdr) == 14); typedef struct _virNWFilterSnoopDHCPHdr virNWFilterSnoopDHCPHdr; typedef virNWFilterSnoopDHCPHdr *virNWFilterSnoopDHCPHdrPtr; @@ -208,7 +208,7 @@ struct _virNWFilterSnoopDHCPHdr { char d_file[128]; uint8_t d_opts[]; } ATTRIBUTE_PACKED; -verify(sizeof(struct _virNWFilterSnoopDHCPHdr) == 236); +G_STATIC_ASSERT(sizeof(struct _virNWFilterSnoopDHCPHdr) == 236); /* DHCP options */ diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 7d584a2980..2f29e8209c 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -44,7 +44,7 @@ typedef enum { QEMU_BLOCKJOB_STATE_PIVOTING, QEMU_BLOCKJOB_STATE_LAST } qemuBlockjobState; -verify((int)QEMU_BLOCKJOB_STATE_NEW == VIR_DOMAIN_BLOCK_JOB_LAST); +G_STATIC_ASSERT((int)QEMU_BLOCKJOB_STATE_NEW == VIR_DOMAIN_BLOCK_JOB_LAST); VIR_ENUM_DECL(qemuBlockjobState); @@ -67,7 +67,7 @@ typedef enum { QEMU_BLOCKJOB_TYPE_BROKEN, QEMU_BLOCKJOB_TYPE_LAST } qemuBlockJobType; -verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL == VIR_DOMAIN_BLOCK_JOB_TYPE_LAST); +G_STATIC_ASSERT((int)QEMU_BLOCKJOB_TYPE_INTERNAL == VIR_DOMAIN_BLOCK_JOB_TYPE_LAST); VIR_ENUM_DECL(qemuBlockjob); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index da0c7a257f..0867116096 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2490,7 +2490,7 @@ static const char *preferredMachines[] = "sim", /* VIR_ARCH_XTENSA */ "sim", /* VIR_ARCH_XTENSAEB */ }; -verify(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST); void diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d6b1e9f00c..d01b4eb76f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2765,7 +2765,7 @@ qemuDomainGetControlInfo(virDomainPtr dom, #define QEMU_SAVE_PARTIAL "LibvirtQemudPart" #define QEMU_SAVE_VERSION 2 -verify(sizeof(QEMU_SAVE_MAGIC) == sizeof(QEMU_SAVE_PARTIAL)); +G_STATIC_ASSERT(sizeof(QEMU_SAVE_MAGIC) == sizeof(QEMU_SAVE_PARTIAL)); typedef enum { QEMU_SAVE_FORMAT_RAW = 0, diff --git a/src/qemu/qemu_firmware.h b/src/qemu/qemu_firmware.h index 37cbfae39d..2fdd71ba52 100644 --- a/src/qemu/qemu_firmware.h +++ b/src/qemu/qemu_firmware.h @@ -57,4 +57,4 @@ qemuFirmwareGetSupported(const char *machine, virFirmwarePtr **fws, size_t *nfws); -verify(VIR_DOMAIN_OS_DEF_FIRMWARE_LAST <= 64); +G_STATIC_ASSERT(VIR_DOMAIN_OS_DEF_FIRMWARE_LAST <= 64); diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 9430ce1d00..1b28e5e031 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -218,7 +218,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(G_N_ELEMENTS(qemuMigrationParamTypes) == QEMU_MIGRATION_PARAM_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(qemuMigrationParamTypes) == QEMU_MIGRATION_PARAM_LAST); virBitmapPtr diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 995d463266..9fd49161ce 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1332,7 +1332,7 @@ static virConnectDomainEventGenericCallback domainEventCallbacks[] = { VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockThreshold), }; -verify(G_N_ELEMENTS(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST); static int remoteRelayNetworkEventLifecycle(virConnectPtr conn, @@ -1369,7 +1369,7 @@ static virConnectNetworkEventGenericCallback networkEventCallbacks[] = { VIR_NETWORK_EVENT_CALLBACK(remoteRelayNetworkEventLifecycle), }; -verify(G_N_ELEMENTS(networkEventCallbacks) == VIR_NETWORK_EVENT_ID_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(networkEventCallbacks) == VIR_NETWORK_EVENT_ID_LAST); static int remoteRelayStoragePoolEventLifecycle(virConnectPtr conn, @@ -1436,7 +1436,7 @@ static virConnectStoragePoolEventGenericCallback storageEventCallbacks[] = { VIR_STORAGE_POOL_EVENT_CALLBACK(remoteRelayStoragePoolEventRefresh), }; -verify(G_N_ELEMENTS(storageEventCallbacks) == VIR_STORAGE_POOL_EVENT_ID_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(storageEventCallbacks) == VIR_STORAGE_POOL_EVENT_ID_LAST); static int remoteRelayNodeDeviceEventLifecycle(virConnectPtr conn, @@ -1503,7 +1503,7 @@ static virConnectNodeDeviceEventGenericCallback nodeDeviceEventCallbacks[] = { VIR_NODE_DEVICE_EVENT_CALLBACK(remoteRelayNodeDeviceEventUpdate), }; -verify(G_N_ELEMENTS(nodeDeviceEventCallbacks) == VIR_NODE_DEVICE_EVENT_ID_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(nodeDeviceEventCallbacks) == VIR_NODE_DEVICE_EVENT_ID_LAST); static int remoteRelaySecretEventLifecycle(virConnectPtr conn, @@ -1570,7 +1570,7 @@ static virConnectSecretEventGenericCallback secretEventCallbacks[] = { VIR_SECRET_EVENT_CALLBACK(remoteRelaySecretEventValueChanged), }; -verify(G_N_ELEMENTS(secretEventCallbacks) == VIR_SECRET_EVENT_ID_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(secretEventCallbacks) == VIR_SECRET_EVENT_ID_LAST); static void remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, diff --git a/src/util/virarch.c b/src/util/virarch.c index f41e3e86bb..b132e178c3 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -25,7 +25,6 @@ #include "virlog.h" #include "virarch.h" -#include "verify.h" VIR_LOG_INIT("util.arch"); @@ -81,7 +80,7 @@ static const struct virArchData { { "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN }, }; -verify(G_N_ELEMENTS(virArchData) == VIR_ARCH_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(virArchData) == VIR_ARCH_LAST); /** diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 3eefe78787..15263f534a 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -49,7 +49,7 @@ VIR_ENUM_DECL(virCgroupController); * bit array stored in int. Like this: * 1 << VIR_CGROUP_CONTROLLER_CPU * Make sure we will not overflow */ -verify(VIR_CGROUP_CONTROLLER_LAST < 8 * sizeof(int)); +G_STATIC_ASSERT(VIR_CGROUP_CONTROLLER_LAST < 8 * sizeof(int)); typedef enum { VIR_CGROUP_THREAD_VCPU = 0, diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index 87fabfbba1..90aed32c53 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -47,7 +47,7 @@ struct virHashInfo { }; -verify(G_N_ELEMENTS(hashinfo) == VIR_CRYPTO_HASH_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(hashinfo) == VIR_CRYPTO_HASH_LAST); ssize_t virCryptoHashBuf(virCryptoHash hash, diff --git a/src/util/virenum.h b/src/util/virenum.h index d68421b203..d74af35530 100644 --- a/src/util/virenum.h +++ b/src/util/virenum.h @@ -42,7 +42,7 @@ virEnumToString(const char * const *types, G_N_ELEMENTS(name ## TypeList), \ type); \ } \ - verify(G_N_ELEMENTS(name ## TypeList) == lastVal) + G_STATIC_ASSERT(G_N_ELEMENTS(name ## TypeList) == lastVal) #define VIR_ENUM_DECL(name) \ const char *name ## TypeToString(int type); \ @@ -72,6 +72,6 @@ virTristateSwitch virTristateSwitchFromBool(bool val); /* the two enums must be in sync to be able to use helpers interchangeably in * some special cases */ -verify((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON); -verify((int)VIR_TRISTATE_BOOL_NO == (int)VIR_TRISTATE_SWITCH_OFF); -verify((int)VIR_TRISTATE_BOOL_ABSENT == (int)VIR_TRISTATE_SWITCH_ABSENT); +G_STATIC_ASSERT((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON); +G_STATIC_ASSERT((int)VIR_TRISTATE_BOOL_NO == (int)VIR_TRISTATE_SWITCH_OFF); +G_STATIC_ASSERT((int)VIR_TRISTATE_BOOL_ABSENT == (int)VIR_TRISTATE_SWITCH_ABSENT); diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c index 955e8f398e..d7e29f24c3 100644 --- a/src/util/virinitctl.c +++ b/src/util/virinitctl.c @@ -96,9 +96,9 @@ struct virInitctlRequest { }; # ifdef MAXHOSTNAMELEN - verify(sizeof(struct virInitctlRequest) == 320 + MAXHOSTNAMELEN); + G_STATIC_ASSERT(sizeof(struct virInitctlRequest) == 320 + MAXHOSTNAMELEN); # else - verify(sizeof(struct virInitctlRequest) == 384); + G_STATIC_ASSERT(sizeof(struct virInitctlRequest) == 384); # endif diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c index 1a0a94e3ab..1475f69b84 100644 --- a/src/util/virkeycode.c +++ b/src/util/virkeycode.c @@ -56,17 +56,17 @@ static const unsigned short *virKeymapValues[VIR_KEYCODE_SET_LAST] = { #define VIR_KEYMAP_ENTRY_MAX G_N_ELEMENTS(virKeyCodeTable_linux) -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)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset1)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset2)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset3)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_osx)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_xtkbd)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_usb)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_win32)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_qnum)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_linux)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_osx)); +G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_win32)); VIR_ENUM_IMPL(virKeycodeSet, VIR_KEYCODE_SET_LAST, diff --git a/src/util/virmacaddr.h b/src/util/virmacaddr.h index 0296cfa965..e43ac3f32a 100644 --- a/src/util/virmacaddr.h +++ b/src/util/virmacaddr.h @@ -38,7 +38,7 @@ struct _virMacAddr { * must not have any extra members added - it must remain exactly * 6 bytes in length. */ -verify(sizeof(struct _virMacAddr) == 6); +G_STATIC_ASSERT(sizeof(struct _virMacAddr) == 6); int virMacAddrCompare(const char *mac1, const char *mac2); diff --git a/src/util/virobject.h b/src/util/virobject.h index 5c4bcf4dde..62a8a3d132 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -80,10 +80,10 @@ virClassPtr virClassForObjectRWLockable(void); * function or as a macro defined to NULL. */ #define VIR_CLASS_NEW(name, prnt) \ - verify_expr(offsetof(name, parent) == 0, \ - (name##Class = virClassNew(prnt, #name, sizeof(name), \ - sizeof(((name *)NULL)->parent), \ - name##Dispose))) + (G_STATIC_ASSERT_EXPR(offsetof(name, parent) == 0), \ + (name##Class = virClassNew(prnt, #name, sizeof(name),\ + sizeof(((name *)NULL)->parent), \ + name##Dispose))) virClassPtr virClassNew(virClassPtr parent, diff --git a/src/util/virperf.c b/src/util/virperf.c index fe2c3f8864..29c388a1f2 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -168,7 +168,7 @@ static struct virPerfEventAttr attrs[] = { .attrConfig = PERF_COUNT_SW_EMULATION_FAULTS }, }; -verify(G_N_ELEMENTS(attrs) == VIR_PERF_EVENT_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(attrs) == VIR_PERF_EVENT_LAST); typedef struct virPerfEventAttr *virPerfEventAttrPtr; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 1397f532fd..90e9b6796e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -386,7 +386,7 @@ static struct FileTypeInfo const fileTypeInfo[] = { 4+4+4, 8, 512, NULL, vmdk4GetBackingStore, NULL }, }; -verify(G_N_ELEMENTS(fileTypeInfo) == VIR_STORAGE_FILE_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(fileTypeInfo) == VIR_STORAGE_FILE_LAST); /* qcow2 compatible features in the order they appear on-disk */ @@ -400,7 +400,7 @@ enum qcow2CompatibleFeature { static const int qcow2CompatibleFeatureArray[] = { VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS, }; -verify(G_N_ELEMENTS(qcow2CompatibleFeatureArray) == +G_STATIC_ASSERT(G_N_ELEMENTS(qcow2CompatibleFeatureArray) == QCOW2_COMPATIBLE_FEATURE_LAST); static int diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index ea48ee5009..3ac2e68144 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -33,7 +33,7 @@ */ #define VIR_TYPED_PARAM_MULTIPLE (1U << 31) -verify(!(VIR_TYPED_PARAM_LAST & VIR_TYPED_PARAM_MULTIPLE)); +G_STATIC_ASSERT(!(VIR_TYPED_PARAM_LAST & VIR_TYPED_PARAM_MULTIPLE)); typedef struct _virTypedParameterRemoteValue virTypedParameterRemoteValue; typedef struct virTypedParameterRemoteValue *virTypedParameterRemoteValuePtr; diff --git a/src/util/virutil.c b/src/util/virutil.c index a0fd7618ee..beb890a7f4 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -68,7 +68,6 @@ #include "virlog.h" #include "virbuffer.h" #include "viralloc.h" -#include "verify.h" #include "virfile.h" #include "vircommand.h" #include "nonblocking.h" @@ -76,7 +75,7 @@ #include "virstring.h" #include "virutil.h" -verify(sizeof(gid_t) <= sizeof(unsigned int) && +G_STATIC_ASSERT(sizeof(gid_t) <= sizeof(unsigned int) && sizeof(uid_t) <= sizeof(unsigned int)); #define VIR_FROM_THIS VIR_FROM_NONE diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index bcdbb50404..bd427fb07e 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -122,7 +122,7 @@ vzBuildCapabilities(void) if (virCapabilitiesInitCaches(caps) < 0) goto error; - verify(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators)); + G_STATIC_ASSERT(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators)); for (i = 0; i < G_N_ELEMENTS(ostypes); i++) for (j = 0; j < G_N_ELEMENTS(archs); j++) diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 1f195ab4b9..88f50185e5 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -20,7 +20,6 @@ #include "testutils.h" -#include "verify.h" #include "virerror.h" #include "viralloc.h" #include "virfile.h" @@ -420,9 +419,9 @@ struct stringToLongData { * not guaranteed by POSIX. Good luck to you if you are crazy enough * to try and port libvirt to a platform with 16-bit int. Gnulib * already assumes that signed integers are two's complement. */ -verify(sizeof(int) == 4); -verify(sizeof(long) == sizeof(int) || sizeof(long) == sizeof(long long)); -verify(sizeof(long long) == 8); +G_STATIC_ASSERT(sizeof(int) == 4); +G_STATIC_ASSERT(sizeof(long) == sizeof(int) || sizeof(long) == sizeof(long long)); +G_STATIC_ASSERT(sizeof(long long) == 8); static int testStringToLong(const void *opaque) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 358067dce4..a74817cd91 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13478,7 +13478,7 @@ virshDomainEventCallback virshDomainEventCallbacks[] = { { "block-threshold", VIR_DOMAIN_EVENT_CALLBACK(virshEventBlockThresholdPrint), }, }; -verify(VIR_DOMAIN_EVENT_ID_LAST == G_N_ELEMENTS(virshDomainEventCallbacks)); +G_STATIC_ASSERT(VIR_DOMAIN_EVENT_ID_LAST == G_N_ELEMENTS(virshDomainEventCallbacks)); static const vshCmdInfo info_event[] = { {.name = "help", diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 700cb0d3e1..a02c85fcb1 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -1242,7 +1242,7 @@ virshNetworkEventCallback virshNetworkEventCallbacks[] = { { "lifecycle", VIR_NETWORK_EVENT_CALLBACK(vshEventLifecyclePrint), }, }; -verify(VIR_NETWORK_EVENT_ID_LAST == G_N_ELEMENTS(virshNetworkEventCallbacks)); +G_STATIC_ASSERT(VIR_NETWORK_EVENT_ID_LAST == G_N_ELEMENTS(virshNetworkEventCallbacks)); static const vshCmdInfo info_network_event[] = { {.name = "help", diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index cb2fc26d1a..68790ea802 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -845,7 +845,7 @@ virshNodeDeviceEventCallback virshNodeDeviceEventCallbacks[] = { VIR_NODE_DEVICE_EVENT_CALLBACK(vshEventLifecyclePrint), }, { "update", vshEventGenericPrint, } }; -verify(VIR_NODE_DEVICE_EVENT_ID_LAST == G_N_ELEMENTS(virshNodeDeviceEventCallbacks)); +G_STATIC_ASSERT(VIR_NODE_DEVICE_EVENT_ID_LAST == G_N_ELEMENTS(virshNodeDeviceEventCallbacks)); static const vshCmdInfo info_node_device_event[] = { diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index feae0787cb..9c32449fbb 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1972,7 +1972,7 @@ virshPoolEventCallback virshPoolEventCallbacks[] = { VIR_STORAGE_POOL_EVENT_CALLBACK(vshEventLifecyclePrint), }, { "refresh", vshEventGenericPrint, } }; -verify(VIR_STORAGE_POOL_EVENT_ID_LAST == G_N_ELEMENTS(virshPoolEventCallbacks)); +G_STATIC_ASSERT(VIR_STORAGE_POOL_EVENT_ID_LAST == G_N_ELEMENTS(virshPoolEventCallbacks)); static const vshCmdInfo info_pool_event[] = { diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 66369a25dc..01c62b9ce8 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -649,7 +649,7 @@ virshSecretEventCallback virshSecretEventCallbacks[] = { VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), }, { "value-changed", vshEventGenericPrint, }, }; -verify(VIR_SECRET_EVENT_ID_LAST == G_N_ELEMENTS(virshSecretEventCallbacks)); +G_STATIC_ASSERT(VIR_SECRET_EVENT_ID_LAST == G_N_ELEMENTS(virshSecretEventCallbacks)); static const vshCmdInfo info_secret_event[] = { {.name = "help", diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index bce0f14917..6a715ede76 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -96,7 +96,7 @@ static const char * failMessages[] = { N_("NOTE"), }; -verify(G_N_ELEMENTS(failMessages) == VIR_HOST_VALIDATE_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(failMessages) == VIR_HOST_VALIDATE_LAST); static const char *failEscapeCodes[] = { "\033[31m", @@ -104,7 +104,7 @@ static const char *failEscapeCodes[] = { "\033[34m", }; -verify(G_N_ELEMENTS(failEscapeCodes) == VIR_HOST_VALIDATE_LAST); +G_STATIC_ASSERT(G_N_ELEMENTS(failEscapeCodes) == VIR_HOST_VALIDATE_LAST); void virHostMsgFail(virHostValidateLevel level, const char *format, -- 2.24.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list