[common] all: switch asserts to DEBUG_ASSERT

This commit is contained in:
Quantum 2021-08-13 19:32:37 -04:00 committed by Geoffrey McRae
parent 4f7ce91e7f
commit b2630024a7
4 changed files with 20 additions and 24 deletions

View File

@ -26,7 +26,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
struct OptionGroup struct OptionGroup
{ {
@ -687,7 +686,7 @@ void option_print(void)
"Value" "Value"
); );
assert(maxLen > 0); DEBUG_ASSERT(maxLen > 0);
headerLine = line; headerLine = line;
stringlist_push(lines, line); stringlist_push(lines, line);
@ -709,7 +708,7 @@ void option_print(void)
o->description o->description
); );
assert(len > 0); DEBUG_ASSERT(len > 0);
stringlist_push(lines, line); stringlist_push(lines, line);
if (len > maxLen) if (len > maxLen)
maxLen = len; 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); DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return -1; return -1;
} }
assert(o->type == OPTION_TYPE_INT); DEBUG_ASSERT(o->type == OPTION_TYPE_INT);
return o->value.x_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); DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return NULL; return NULL;
} }
assert(o->type == OPTION_TYPE_STRING); DEBUG_ASSERT(o->type == OPTION_TYPE_STRING);
return o->value.x_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); DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return false; return false;
} }
assert(o->type == OPTION_TYPE_BOOL); DEBUG_ASSERT(o->type == OPTION_TYPE_BOOL);
return o->value.x_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); DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return false; return false;
} }
assert(o->type == OPTION_TYPE_FLOAT); DEBUG_ASSERT(o->type == OPTION_TYPE_FLOAT);
return o->value.x_float; return o->value.x_float;
} }

View File

@ -24,7 +24,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include <assert.h>
#include <errno.h> #include <errno.h>
#include <stdatomic.h> #include <stdatomic.h>
#include <stdint.h> #include <stdint.h>
@ -78,7 +77,7 @@ LGEvent * lgCreateEvent(bool autoReset, unsigned int msSpinTime)
void lgFreeEvent(LGEvent * handle) void lgFreeEvent(LGEvent * handle)
{ {
assert(handle); DEBUG_ASSERT(handle);
if (atomic_load_explicit(&handle->waiting, memory_order_acquire) != 0) if (atomic_load_explicit(&handle->waiting, memory_order_acquire) != 0)
DEBUG_ERROR("BUG: Freeing an event that still has threads waiting on it"); 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) bool lgWaitEventAbs(LGEvent * handle, struct timespec * ts)
{ {
assert(handle); DEBUG_ASSERT(handle);
bool ret = true; bool ret = true;
int res; int res;
@ -173,7 +172,7 @@ bool lgWaitEvent(LGEvent * handle, unsigned int timeout)
bool lgSignalEvent(LGEvent * handle) bool lgSignalEvent(LGEvent * handle)
{ {
assert(handle); DEBUG_ASSERT(handle);
if (pthread_mutex_lock(&handle->mutex) != 0) if (pthread_mutex_lock(&handle->mutex) != 0)
{ {
@ -202,6 +201,6 @@ bool lgSignalEvent(LGEvent * handle)
bool lgResetEvent(LGEvent * handle) bool lgResetEvent(LGEvent * handle)
{ {
assert(handle); DEBUG_ASSERT(handle);
return atomic_exchange_explicit(&handle->signaled, false, memory_order_release); return atomic_exchange_explicit(&handle->signaled, false, memory_order_release);
} }

View File

@ -20,7 +20,6 @@
#include "common/ivshmem.h" #include "common/ivshmem.h"
#include <assert.h>
#include <dirent.h> #include <dirent.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -118,7 +117,7 @@ bool ivshmemOpen(struct IVSHMEM * dev)
bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice)
{ {
assert(dev); DEBUG_ASSERT(dev);
unsigned int devSize; unsigned int devSize;
int devFd = -1; int devFd = -1;
@ -186,7 +185,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice)
void ivshmemClose(struct IVSHMEM * dev) void ivshmemClose(struct IVSHMEM * dev)
{ {
assert(dev); DEBUG_ASSERT(dev);
if (!dev->opaque) if (!dev->opaque)
return; return;
@ -210,7 +209,7 @@ void ivshmemFree(struct IVSHMEM * dev)
bool ivshmemHasDMA(struct IVSHMEM * dev) bool ivshmemHasDMA(struct IVSHMEM * dev)
{ {
assert(dev && dev->opaque); DEBUG_ASSERT(dev && dev->opaque);
struct IVSHMEMInfo * info = struct IVSHMEMInfo * info =
(struct IVSHMEMInfo *)dev->opaque; (struct IVSHMEMInfo *)dev->opaque;
@ -220,9 +219,9 @@ bool ivshmemHasDMA(struct IVSHMEM * dev)
int ivshmemGetDMABuf(struct IVSHMEM * dev, uint64_t offset, uint64_t size) int ivshmemGetDMABuf(struct IVSHMEM * dev, uint64_t offset, uint64_t size)
{ {
assert(ivshmemHasDMA(dev)); DEBUG_ASSERT(ivshmemHasDMA(dev));
assert(dev && dev->opaque); DEBUG_ASSERT(dev && dev->opaque);
assert(offset + size <= dev->size); DEBUG_ASSERT(offset + size <= dev->size);
static long pageSize = 0; static long pageSize = 0;

View File

@ -25,7 +25,6 @@
#include <windows.h> #include <windows.h>
#include "ivshmem.h" #include "ivshmem.h"
#include <assert.h>
#include <setupapi.h> #include <setupapi.h>
#include <io.h> #include <io.h>
@ -72,7 +71,7 @@ static int ivshmemComparator(const void * a_, const void * b_)
bool ivshmemInit(struct IVSHMEM * dev) bool ivshmemInit(struct IVSHMEM * dev)
{ {
assert(dev && !dev->opaque); DEBUG_ASSERT(dev && !dev->opaque);
HANDLE handle; HANDLE handle;
HDEVINFO devInfoSet; HDEVINFO devInfoSet;
@ -195,7 +194,7 @@ bool ivshmemInit(struct IVSHMEM * dev)
bool ivshmemOpen(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; struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque;
@ -226,7 +225,7 @@ bool ivshmemOpen(struct IVSHMEM * dev)
void ivshmemClose(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; struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque;
@ -239,7 +238,7 @@ void ivshmemClose(struct IVSHMEM * dev)
void ivshmemFree(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; struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)dev->opaque;