From b2630024a7c5edba79985284b91563e585b2e63d Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 13 Aug 2021 19:32:37 -0400 Subject: [PATCH] [common] all: switch asserts to DEBUG_ASSERT --- common/src/option.c | 13 ++++++------- common/src/platform/linux/event.c | 9 ++++----- common/src/platform/linux/ivshmem.c | 13 ++++++------- common/src/platform/windows/ivshmem.c | 9 ++++----- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/common/src/option.c b/common/src/option.c index 3e2fea76..d0039451 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -26,7 +26,6 @@ #include #include #include -#include struct OptionGroup { @@ -687,7 +686,7 @@ void option_print(void) "Value" ); - assert(maxLen > 0); + DEBUG_ASSERT(maxLen > 0); headerLine = line; stringlist_push(lines, line); @@ -709,7 +708,7 @@ void option_print(void) o->description ); - assert(len > 0); + DEBUG_ASSERT(len > 0); stringlist_push(lines, line); if (len > maxLen) maxLen = len; @@ -765,7 +764,7 @@ int option_get_int(const char * module, const char * name) DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name); return -1; } - assert(o->type == OPTION_TYPE_INT); + DEBUG_ASSERT(o->type == OPTION_TYPE_INT); return o->value.x_int; } @@ -777,7 +776,7 @@ const char * option_get_string(const char * module, const char * name) DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name); return NULL; } - assert(o->type == OPTION_TYPE_STRING); + DEBUG_ASSERT(o->type == OPTION_TYPE_STRING); return o->value.x_string; } @@ -789,7 +788,7 @@ bool option_get_bool(const char * module, const char * name) DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name); return false; } - assert(o->type == OPTION_TYPE_BOOL); + DEBUG_ASSERT(o->type == OPTION_TYPE_BOOL); return o->value.x_bool; } @@ -801,6 +800,6 @@ float option_get_float(const char * module, const char * name) DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name); return false; } - assert(o->type == OPTION_TYPE_FLOAT); + DEBUG_ASSERT(o->type == OPTION_TYPE_FLOAT); return o->value.x_float; } diff --git a/common/src/platform/linux/event.c b/common/src/platform/linux/event.c index 9b506234..dd30236c 100644 --- a/common/src/platform/linux/event.c +++ b/common/src/platform/linux/event.c @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -78,7 +77,7 @@ LGEvent * lgCreateEvent(bool autoReset, unsigned int msSpinTime) void lgFreeEvent(LGEvent * handle) { - assert(handle); + DEBUG_ASSERT(handle); if (atomic_load_explicit(&handle->waiting, memory_order_acquire) != 0) DEBUG_ERROR("BUG: Freeing an event that still has threads waiting on it"); @@ -90,7 +89,7 @@ void lgFreeEvent(LGEvent * handle) bool lgWaitEventAbs(LGEvent * handle, struct timespec * ts) { - assert(handle); + DEBUG_ASSERT(handle); bool ret = true; int res; @@ -173,7 +172,7 @@ bool lgWaitEvent(LGEvent * handle, unsigned int timeout) bool lgSignalEvent(LGEvent * handle) { - assert(handle); + DEBUG_ASSERT(handle); if (pthread_mutex_lock(&handle->mutex) != 0) { @@ -202,6 +201,6 @@ bool lgSignalEvent(LGEvent * handle) bool lgResetEvent(LGEvent * handle) { - assert(handle); + DEBUG_ASSERT(handle); return atomic_exchange_explicit(&handle->signaled, false, memory_order_release); } diff --git a/common/src/platform/linux/ivshmem.c b/common/src/platform/linux/ivshmem.c index f3d09edf..84660c76 100644 --- a/common/src/platform/linux/ivshmem.c +++ b/common/src/platform/linux/ivshmem.c @@ -20,7 +20,6 @@ #include "common/ivshmem.h" -#include #include #include #include @@ -118,7 +117,7 @@ bool ivshmemOpen(struct IVSHMEM * dev) bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) { - assert(dev); + DEBUG_ASSERT(dev); unsigned int devSize; int devFd = -1; @@ -186,7 +185,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) void ivshmemClose(struct IVSHMEM * dev) { - assert(dev); + DEBUG_ASSERT(dev); if (!dev->opaque) return; @@ -210,7 +209,7 @@ void ivshmemFree(struct IVSHMEM * dev) bool ivshmemHasDMA(struct IVSHMEM * dev) { - assert(dev && dev->opaque); + DEBUG_ASSERT(dev && dev->opaque); struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque; @@ -220,9 +219,9 @@ bool ivshmemHasDMA(struct IVSHMEM * dev) int ivshmemGetDMABuf(struct IVSHMEM * dev, uint64_t offset, uint64_t size) { - assert(ivshmemHasDMA(dev)); - assert(dev && dev->opaque); - assert(offset + size <= dev->size); + DEBUG_ASSERT(ivshmemHasDMA(dev)); + DEBUG_ASSERT(dev && dev->opaque); + DEBUG_ASSERT(offset + size <= dev->size); static long pageSize = 0; diff --git a/common/src/platform/windows/ivshmem.c b/common/src/platform/windows/ivshmem.c index 0b7316e4..486557f2 100644 --- a/common/src/platform/windows/ivshmem.c +++ b/common/src/platform/windows/ivshmem.c @@ -25,7 +25,6 @@ #include #include "ivshmem.h" -#include #include #include @@ -72,7 +71,7 @@ static int ivshmemComparator(const void * a_, const void * b_) bool ivshmemInit(struct IVSHMEM * dev) { - assert(dev && !dev->opaque); + DEBUG_ASSERT(dev && !dev->opaque); HANDLE handle; HDEVINFO devInfoSet; @@ -195,7 +194,7 @@ bool ivshmemInit(struct IVSHMEM * dev) bool ivshmemOpen(struct IVSHMEM * dev) { - assert(dev && dev->opaque && !dev->mem); + DEBUG_ASSERT(dev && dev->opaque && !dev->mem); struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque; @@ -226,7 +225,7 @@ bool ivshmemOpen(struct IVSHMEM * dev) void ivshmemClose(struct IVSHMEM * dev) { - assert(dev && dev->opaque && dev->mem); + DEBUG_ASSERT(dev && dev->opaque && dev->mem); struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque; @@ -239,7 +238,7 @@ void ivshmemClose(struct IVSHMEM * dev) void ivshmemFree(struct IVSHMEM * dev) { - assert(dev && dev->opaque && !dev->mem); + DEBUG_ASSERT(dev && dev->opaque && !dev->mem); struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque;