src: replace verify(expr) with G_STATIC_ASSERT(expr)

G_STATIC_ASSERT() is a drop-in functional equivalent of
the GNULIB verify() macro.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-01-09 10:39:55 +00:00
parent 7b9645a7d1
commit fa434739a0
36 changed files with 69 additions and 80 deletions

View File

@ -1621,12 +1621,6 @@ sc_prohibit_dirent_without_use:
re='\<($(_dirent_syms_re))\>' \ re='\<($(_dirent_syms_re))\>' \
$(_sc_header_without_use) $(_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. # Don't include xfreopen.h unless you use one of its functions.
sc_prohibit_xfreopen_without_use: sc_prohibit_xfreopen_without_use:
@h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use) @h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use)

View File

@ -16,9 +16,9 @@
#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ #if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
&& (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
&& !defined __cplusplus) && !defined __cplusplus)
# define verify(cond) _Static_assert(cond, "verify (" #cond ")") # define G_STATIC_ASSERT(cond) _Static_assert(cond, "verify (" #cond ")")
#else #else
# define verify(cond) # define G_STATIC_ASSERT(cond)
#endif #endif
#ifndef G_GNUC_UNUSED #ifndef G_GNUC_UNUSED
@ -1138,10 +1138,10 @@ struct secretEventData secretEvents[] = {
}; };
/* make sure that the events are kept in sync */ /* make sure that the events are kept in sync */
verify(G_N_ELEMENTS(domainEvents) == VIR_DOMAIN_EVENT_ID_LAST); G_STATIC_ASSERT(G_N_ELEMENTS(domainEvents) == VIR_DOMAIN_EVENT_ID_LAST);
verify(G_N_ELEMENTS(storagePoolEvents) == VIR_STORAGE_POOL_EVENT_ID_LAST); G_STATIC_ASSERT(G_N_ELEMENTS(storagePoolEvents) == VIR_STORAGE_POOL_EVENT_ID_LAST);
verify(G_N_ELEMENTS(nodeDeviceEvents) == VIR_NODE_DEVICE_EVENT_ID_LAST); G_STATIC_ASSERT(G_N_ELEMENTS(nodeDeviceEvents) == VIR_NODE_DEVICE_EVENT_ID_LAST);
verify(G_N_ELEMENTS(secretEvents) == VIR_SECRET_EVENT_ID_LAST); G_STATIC_ASSERT(G_N_ELEMENTS(secretEvents) == VIR_SECRET_EVENT_ID_LAST);
int int
main(int argc, char **argv) main(int argc, char **argv)

View File

@ -56,7 +56,7 @@ typedef enum {
VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT, VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT,
VIR_DOMAIN_SNAPSHOT_LAST VIR_DOMAIN_SNAPSHOT_LAST
} virDomainSnapshotState; } 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 */ /* Stores disk-snapshot information */
typedef struct _virDomainSnapshotDiskDef virDomainSnapshotDiskDef; typedef struct _virDomainSnapshotDiskDef virDomainSnapshotDiskDef;

View File

@ -91,13 +91,13 @@ virDomainCheckpointObjListGetNames(virDomainCheckpointObjListPtr checkpoints,
unsigned int flags) unsigned int flags)
{ {
/* We intentionally chose our public flags to match the common 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); (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); (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); (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); (int) VIR_DOMAIN_MOMENT_LIST_NO_LEAVES);
return virDomainMomentObjListGetNames(checkpoints->base, from, names, return virDomainMomentObjListGetNames(checkpoints->base, from, names,

View File

@ -41,7 +41,7 @@
* The UUID of a network is the MD5 sum of its key. Therefore, verify that * 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. * 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 static int

View File

@ -43,7 +43,7 @@
* The UUID of a storage pool is the MD5 sum of its mount path. Therefore, * 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 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);

View File

@ -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, * 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 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);

View File

@ -22,7 +22,6 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <verify.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>

View File

@ -26,7 +26,6 @@
#include "virerror.h" #include "virerror.h"
#include "virconf.h" #include "virconf.h"
#include "viralloc.h" #include "viralloc.h"
#include "verify.h"
#include "xenxs_private.h" #include "xenxs_private.h"
#include "xen_xm.h" #include "xen_xm.h"
#include "domain_conf.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 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */ 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. * Convert a virDomainDef object into an XM config record.

View File

@ -186,7 +186,7 @@ struct _virNWFilterSnoopEthHdr {
uint16_t eh_type; uint16_t eh_type;
uint8_t eh_data[]; uint8_t eh_data[];
} ATTRIBUTE_PACKED; } ATTRIBUTE_PACKED;
verify(sizeof(struct _virNWFilterSnoopEthHdr) == 14); G_STATIC_ASSERT(sizeof(struct _virNWFilterSnoopEthHdr) == 14);
typedef struct _virNWFilterSnoopDHCPHdr virNWFilterSnoopDHCPHdr; typedef struct _virNWFilterSnoopDHCPHdr virNWFilterSnoopDHCPHdr;
typedef virNWFilterSnoopDHCPHdr *virNWFilterSnoopDHCPHdrPtr; typedef virNWFilterSnoopDHCPHdr *virNWFilterSnoopDHCPHdrPtr;
@ -208,7 +208,7 @@ struct _virNWFilterSnoopDHCPHdr {
char d_file[128]; char d_file[128];
uint8_t d_opts[]; uint8_t d_opts[];
} ATTRIBUTE_PACKED; } ATTRIBUTE_PACKED;
verify(sizeof(struct _virNWFilterSnoopDHCPHdr) == 236); G_STATIC_ASSERT(sizeof(struct _virNWFilterSnoopDHCPHdr) == 236);
/* DHCP options */ /* DHCP options */

View File

@ -44,7 +44,7 @@ typedef enum {
QEMU_BLOCKJOB_STATE_PIVOTING, QEMU_BLOCKJOB_STATE_PIVOTING,
QEMU_BLOCKJOB_STATE_LAST QEMU_BLOCKJOB_STATE_LAST
} qemuBlockjobState; } 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); VIR_ENUM_DECL(qemuBlockjobState);
@ -67,7 +67,7 @@ typedef enum {
QEMU_BLOCKJOB_TYPE_BROKEN, QEMU_BLOCKJOB_TYPE_BROKEN,
QEMU_BLOCKJOB_TYPE_LAST QEMU_BLOCKJOB_TYPE_LAST
} qemuBlockJobType; } 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); VIR_ENUM_DECL(qemuBlockjob);

View File

@ -2491,7 +2491,7 @@ static const char *preferredMachines[] =
"sim", /* VIR_ARCH_XTENSA */ "sim", /* VIR_ARCH_XTENSA */
"sim", /* VIR_ARCH_XTENSAEB */ "sim", /* VIR_ARCH_XTENSAEB */
}; };
verify(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST); G_STATIC_ASSERT(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST);
void void

View File

@ -2765,7 +2765,7 @@ qemuDomainGetControlInfo(virDomainPtr dom,
#define QEMU_SAVE_PARTIAL "LibvirtQemudPart" #define QEMU_SAVE_PARTIAL "LibvirtQemudPart"
#define QEMU_SAVE_VERSION 2 #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 { typedef enum {
QEMU_SAVE_FORMAT_RAW = 0, QEMU_SAVE_FORMAT_RAW = 0,

View File

@ -57,4 +57,4 @@ qemuFirmwareGetSupported(const char *machine,
virFirmwarePtr **fws, virFirmwarePtr **fws,
size_t *nfws); size_t *nfws);
verify(VIR_DOMAIN_OS_DEF_FIRMWARE_LAST <= 64); G_STATIC_ASSERT(VIR_DOMAIN_OS_DEF_FIRMWARE_LAST <= 64);

View File

@ -218,7 +218,7 @@ static const qemuMigrationParamType qemuMigrationParamTypes[] = {
[QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH] = QEMU_MIGRATION_PARAM_TYPE_ULL, [QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH] = QEMU_MIGRATION_PARAM_TYPE_ULL,
[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS] = QEMU_MIGRATION_PARAM_TYPE_INT, [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 virBitmapPtr

View File

@ -1331,7 +1331,7 @@ static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockThreshold), 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 static int
remoteRelayNetworkEventLifecycle(virConnectPtr conn, remoteRelayNetworkEventLifecycle(virConnectPtr conn,
@ -1368,7 +1368,7 @@ static virConnectNetworkEventGenericCallback networkEventCallbacks[] = {
VIR_NETWORK_EVENT_CALLBACK(remoteRelayNetworkEventLifecycle), 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 static int
remoteRelayStoragePoolEventLifecycle(virConnectPtr conn, remoteRelayStoragePoolEventLifecycle(virConnectPtr conn,
@ -1435,7 +1435,7 @@ static virConnectStoragePoolEventGenericCallback storageEventCallbacks[] = {
VIR_STORAGE_POOL_EVENT_CALLBACK(remoteRelayStoragePoolEventRefresh), 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 static int
remoteRelayNodeDeviceEventLifecycle(virConnectPtr conn, remoteRelayNodeDeviceEventLifecycle(virConnectPtr conn,
@ -1502,7 +1502,7 @@ static virConnectNodeDeviceEventGenericCallback nodeDeviceEventCallbacks[] = {
VIR_NODE_DEVICE_EVENT_CALLBACK(remoteRelayNodeDeviceEventUpdate), 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 static int
remoteRelaySecretEventLifecycle(virConnectPtr conn, remoteRelaySecretEventLifecycle(virConnectPtr conn,
@ -1569,7 +1569,7 @@ static virConnectSecretEventGenericCallback secretEventCallbacks[] = {
VIR_SECRET_EVENT_CALLBACK(remoteRelaySecretEventValueChanged), 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 static void
remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,

View File

@ -25,7 +25,6 @@
#include "virlog.h" #include "virlog.h"
#include "virarch.h" #include "virarch.h"
#include "verify.h"
VIR_LOG_INIT("util.arch"); VIR_LOG_INIT("util.arch");
@ -81,7 +80,7 @@ static const struct virArchData {
{ "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN }, { "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN },
}; };
verify(G_N_ELEMENTS(virArchData) == VIR_ARCH_LAST); G_STATIC_ASSERT(G_N_ELEMENTS(virArchData) == VIR_ARCH_LAST);
/** /**

View File

@ -49,7 +49,7 @@ VIR_ENUM_DECL(virCgroupController);
* bit array stored in int. Like this: * bit array stored in int. Like this:
* 1 << VIR_CGROUP_CONTROLLER_CPU * 1 << VIR_CGROUP_CONTROLLER_CPU
* Make sure we will not overflow */ * 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 { typedef enum {
VIR_CGROUP_THREAD_VCPU = 0, VIR_CGROUP_THREAD_VCPU = 0,

View File

@ -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 ssize_t
virCryptoHashBuf(virCryptoHash hash, virCryptoHashBuf(virCryptoHash hash,

View File

@ -42,7 +42,7 @@ virEnumToString(const char * const *types,
G_N_ELEMENTS(name ## TypeList), \ G_N_ELEMENTS(name ## TypeList), \
type); \ type); \
} \ } \
verify(G_N_ELEMENTS(name ## TypeList) == lastVal) G_STATIC_ASSERT(G_N_ELEMENTS(name ## TypeList) == lastVal)
#define VIR_ENUM_DECL(name) \ #define VIR_ENUM_DECL(name) \
const char *name ## TypeToString(int type); \ 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 /* the two enums must be in sync to be able to use helpers interchangeably in
* some special cases */ * some special cases */
verify((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON); G_STATIC_ASSERT((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON);
verify((int)VIR_TRISTATE_BOOL_NO == (int)VIR_TRISTATE_SWITCH_OFF); G_STATIC_ASSERT((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_ABSENT == (int)VIR_TRISTATE_SWITCH_ABSENT);

View File

@ -96,9 +96,9 @@ struct virInitctlRequest {
}; };
# ifdef MAXHOSTNAMELEN # ifdef MAXHOSTNAMELEN
verify(sizeof(struct virInitctlRequest) == 320 + MAXHOSTNAMELEN); G_STATIC_ASSERT(sizeof(struct virInitctlRequest) == 320 + MAXHOSTNAMELEN);
# else # else
verify(sizeof(struct virInitctlRequest) == 384); G_STATIC_ASSERT(sizeof(struct virInitctlRequest) == 384);
# endif # endif

View File

@ -56,17 +56,17 @@ static const unsigned short *virKeymapValues[VIR_KEYCODE_SET_LAST] = {
#define VIR_KEYMAP_ENTRY_MAX G_N_ELEMENTS(virKeyCodeTable_linux) #define VIR_KEYMAP_ENTRY_MAX G_N_ELEMENTS(virKeyCodeTable_linux)
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset1)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset1));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset2)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset2));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset3)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_atset3));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_osx)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_osx));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_xtkbd)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_xtkbd));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_usb)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_usb));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_win32)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_win32));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_qnum)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyCodeTable_qnum));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_linux)); G_STATIC_ASSERT(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_linux));
verify(VIR_KEYMAP_ENTRY_MAX == G_N_ELEMENTS(virKeyNameTable_osx)); G_STATIC_ASSERT(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(virKeyNameTable_win32));
VIR_ENUM_IMPL(virKeycodeSet, VIR_ENUM_IMPL(virKeycodeSet,
VIR_KEYCODE_SET_LAST, VIR_KEYCODE_SET_LAST,

View File

@ -38,7 +38,7 @@ struct _virMacAddr {
* must not have any extra members added - it must remain exactly * must not have any extra members added - it must remain exactly
* 6 bytes in length. * 6 bytes in length.
*/ */
verify(sizeof(struct _virMacAddr) == 6); G_STATIC_ASSERT(sizeof(struct _virMacAddr) == 6);
int virMacAddrCompare(const char *mac1, const char *mac2); int virMacAddrCompare(const char *mac1, const char *mac2);

View File

@ -80,10 +80,10 @@ virClassPtr virClassForObjectRWLockable(void);
* function or as a macro defined to NULL. * function or as a macro defined to NULL.
*/ */
#define VIR_CLASS_NEW(name, prnt) \ #define VIR_CLASS_NEW(name, prnt) \
verify_expr(offsetof(name, parent) == 0, \ (G_STATIC_ASSERT_EXPR(offsetof(name, parent) == 0), \
(name##Class = virClassNew(prnt, #name, sizeof(name), \ (name##Class = virClassNew(prnt, #name, sizeof(name),\
sizeof(((name *)NULL)->parent), \ sizeof(((name *)NULL)->parent), \
name##Dispose))) name##Dispose)))
virClassPtr virClassPtr
virClassNew(virClassPtr parent, virClassNew(virClassPtr parent,

View File

@ -168,7 +168,7 @@ static struct virPerfEventAttr attrs[] = {
.attrConfig = PERF_COUNT_SW_EMULATION_FAULTS .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; typedef struct virPerfEventAttr *virPerfEventAttrPtr;

View File

@ -386,7 +386,7 @@ static struct FileTypeInfo const fileTypeInfo[] = {
4+4+4, 8, 512, NULL, vmdk4GetBackingStore, NULL 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 */ /* qcow2 compatible features in the order they appear on-disk */
@ -400,7 +400,7 @@ enum qcow2CompatibleFeature {
static const int qcow2CompatibleFeatureArray[] = { static const int qcow2CompatibleFeatureArray[] = {
VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS, VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS,
}; };
verify(G_N_ELEMENTS(qcow2CompatibleFeatureArray) == G_STATIC_ASSERT(G_N_ELEMENTS(qcow2CompatibleFeatureArray) ==
QCOW2_COMPATIBLE_FEATURE_LAST); QCOW2_COMPATIBLE_FEATURE_LAST);
static int static int

View File

@ -33,7 +33,7 @@
*/ */
#define VIR_TYPED_PARAM_MULTIPLE (1U << 31) #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 virTypedParameterRemoteValue;
typedef struct virTypedParameterRemoteValue *virTypedParameterRemoteValuePtr; typedef struct virTypedParameterRemoteValue *virTypedParameterRemoteValuePtr;

View File

@ -68,7 +68,6 @@
#include "virlog.h" #include "virlog.h"
#include "virbuffer.h" #include "virbuffer.h"
#include "viralloc.h" #include "viralloc.h"
#include "verify.h"
#include "virfile.h" #include "virfile.h"
#include "vircommand.h" #include "vircommand.h"
#include "virprocess.h" #include "virprocess.h"
@ -76,7 +75,7 @@
#include "virutil.h" #include "virutil.h"
#include "virsocket.h" #include "virsocket.h"
verify(sizeof(gid_t) <= sizeof(unsigned int) && G_STATIC_ASSERT(sizeof(gid_t) <= sizeof(unsigned int) &&
sizeof(uid_t) <= sizeof(unsigned int)); sizeof(uid_t) <= sizeof(unsigned int));
#define VIR_FROM_THIS VIR_FROM_NONE #define VIR_FROM_THIS VIR_FROM_NONE

View File

@ -122,7 +122,7 @@ vzBuildCapabilities(void)
if (virCapabilitiesInitCaches(caps) < 0) if (virCapabilitiesInitCaches(caps) < 0)
goto error; 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 (i = 0; i < G_N_ELEMENTS(ostypes); i++)
for (j = 0; j < G_N_ELEMENTS(archs); j++) for (j = 0; j < G_N_ELEMENTS(archs); j++)

View File

@ -20,7 +20,6 @@
#include "testutils.h" #include "testutils.h"
#include "verify.h"
#include "virerror.h" #include "virerror.h"
#include "viralloc.h" #include "viralloc.h"
#include "virfile.h" #include "virfile.h"
@ -420,9 +419,9 @@ struct stringToLongData {
* not guaranteed by POSIX. Good luck to you if you are crazy enough * 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 * to try and port libvirt to a platform with 16-bit int. Gnulib
* already assumes that signed integers are two's complement. */ * already assumes that signed integers are two's complement. */
verify(sizeof(int) == 4); G_STATIC_ASSERT(sizeof(int) == 4);
verify(sizeof(long) == sizeof(int) || sizeof(long) == sizeof(long long)); G_STATIC_ASSERT(sizeof(long) == sizeof(int) || sizeof(long) == sizeof(long long));
verify(sizeof(long long) == 8); G_STATIC_ASSERT(sizeof(long long) == 8);
static int static int
testStringToLong(const void *opaque) testStringToLong(const void *opaque)

View File

@ -13513,7 +13513,7 @@ virshDomainEventCallback virshDomainEventCallbacks[] = {
{ "block-threshold", { "block-threshold",
VIR_DOMAIN_EVENT_CALLBACK(virshEventBlockThresholdPrint), }, 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[] = { static const vshCmdInfo info_event[] = {
{.name = "help", {.name = "help",

View File

@ -1242,7 +1242,7 @@ virshNetworkEventCallback virshNetworkEventCallbacks[] = {
{ "lifecycle", { "lifecycle",
VIR_NETWORK_EVENT_CALLBACK(vshEventLifecyclePrint), }, 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[] = { static const vshCmdInfo info_network_event[] = {
{.name = "help", {.name = "help",

View File

@ -845,7 +845,7 @@ virshNodeDeviceEventCallback virshNodeDeviceEventCallbacks[] = {
VIR_NODE_DEVICE_EVENT_CALLBACK(vshEventLifecyclePrint), }, VIR_NODE_DEVICE_EVENT_CALLBACK(vshEventLifecyclePrint), },
{ "update", vshEventGenericPrint, } { "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[] = { static const vshCmdInfo info_node_device_event[] = {

View File

@ -1972,7 +1972,7 @@ virshPoolEventCallback virshPoolEventCallbacks[] = {
VIR_STORAGE_POOL_EVENT_CALLBACK(vshEventLifecyclePrint), }, VIR_STORAGE_POOL_EVENT_CALLBACK(vshEventLifecyclePrint), },
{ "refresh", vshEventGenericPrint, } { "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[] = { static const vshCmdInfo info_pool_event[] = {

View File

@ -649,7 +649,7 @@ virshSecretEventCallback virshSecretEventCallbacks[] = {
VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), }, VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), },
{ "value-changed", vshEventGenericPrint, }, { "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[] = { static const vshCmdInfo info_secret_event[] = {
{.name = "help", {.name = "help",

View File

@ -96,7 +96,7 @@ static const char * failMessages[] = {
N_("NOTE"), 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[] = { static const char *failEscapeCodes[] = {
"\033[31m", "\033[31m",
@ -104,7 +104,7 @@ static const char *failEscapeCodes[] = {
"\033[34m", "\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, void virHostMsgFail(virHostValidateLevel level,
const char *format, const char *format,