From 579f9985195259a0ee5e94f8ee17d67305380b0d Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 13 Aug 2021 19:51:36 -0400 Subject: [PATCH] [client] all: replace assert with DEBUG_ASSERT --- client/displayservers/Wayland/clipboard.c | 3 +- client/include/interface/displayserver.h | 61 +++++++++++----------- client/include/interface/overlay.h | 9 ++-- client/renderers/EGL/desktop_rects.c | 2 +- client/renderers/EGL/model.c | 1 - client/renderers/EGL/texture.c | 5 +- client/renderers/EGL/texture_buffer.c | 5 +- client/renderers/EGL/texture_dmabuf.c | 5 +- client/renderers/EGL/texture_framebuffer.c | 4 +- client/src/app.c | 2 +- client/src/ll.c | 4 +- client/src/main.c | 3 +- 12 files changed, 48 insertions(+), 56 deletions(-) diff --git a/client/displayservers/Wayland/clipboard.c b/client/displayservers/Wayland/clipboard.c index e20f97f3..d7872410 100644 --- a/client/displayservers/Wayland/clipboard.c +++ b/client/displayservers/Wayland/clipboard.c @@ -20,7 +20,6 @@ #include "wayland.h" -#include #include #include @@ -299,7 +298,7 @@ static void dataDeviceHandleEnter(void * data, struct wl_data_device * device, uint32_t serial, struct wl_surface * surface, wl_fixed_t sxW, wl_fixed_t syW, struct wl_data_offer * offer) { - assert(wlCb.dndOffer == NULL); + DEBUG_ASSERT(wlCb.dndOffer == NULL); wlCb.dndOffer = offer; struct DataOffer * extra = wl_data_offer_get_user_data(offer); diff --git a/client/include/interface/displayserver.h b/client/include/interface/displayserver.h index e085ee90..a472582e 100644 --- a/client/include/interface/displayserver.h +++ b/client/include/interface/displayserver.h @@ -24,6 +24,7 @@ #include #include #include "common/types.h" +#include "common/debug.h" typedef enum LG_ClipboardData { @@ -210,50 +211,50 @@ struct LG_DisplayServerOps }; #ifdef ENABLE_EGL - #define ASSERT_EGL_FN(x) assert(x); + #define ASSERT_EGL_FN(x) DEBUG_ASSERT(x) #else #define ASSERT_EGL_FN(x) #endif #ifdef ENABLE_OPENGL - #define ASSERT_OPENGL_FN(x) assert(x) + #define ASSERT_OPENGL_FN(x) DEBUG_ASSERT(x) #else #define ASSERT_OPENGL_FN(x) #endif #define ASSERT_LG_DS_VALID(x) \ - assert((x)->setup ); \ - assert((x)->probe ); \ - assert((x)->earlyInit ); \ - assert((x)->init ); \ - assert((x)->startup ); \ - assert((x)->shutdown ); \ - assert((x)->free ); \ - assert((x)->getProp ); \ - ASSERT_EGL_FN((x)->getEGLDisplay ); \ - ASSERT_EGL_FN((x)->getEGLNativeWindow ); \ - ASSERT_EGL_FN((x)->eglSwapBuffers ); \ + DEBUG_ASSERT((x)->setup ); \ + DEBUG_ASSERT((x)->probe ); \ + DEBUG_ASSERT((x)->earlyInit); \ + DEBUG_ASSERT((x)->init ); \ + DEBUG_ASSERT((x)->startup ); \ + DEBUG_ASSERT((x)->shutdown ); \ + DEBUG_ASSERT((x)->free ); \ + DEBUG_ASSERT((x)->getProp ); \ + ASSERT_EGL_FN((x)->getEGLDisplay ); \ + ASSERT_EGL_FN((x)->getEGLNativeWindow); \ + ASSERT_EGL_FN((x)->eglSwapBuffers ); \ ASSERT_OPENGL_FN((x)->glCreateContext ); \ ASSERT_OPENGL_FN((x)->glDeleteContext ); \ ASSERT_OPENGL_FN((x)->glMakeCurrent ); \ ASSERT_OPENGL_FN((x)->glSetSwapInterval); \ ASSERT_OPENGL_FN((x)->glSwapBuffers ); \ - assert(!(x)->waitFrame == !(x)->stopWaitFrame); \ - assert((x)->guestPointerUpdated); \ - assert((x)->setPointer ); \ - assert((x)->grabPointer ); \ - assert((x)->ungrabPointer ); \ - assert((x)->capturePointer ); \ - assert((x)->uncapturePointer ); \ - assert((x)->warpPointer ); \ - assert((x)->realignPointer ); \ - assert((x)->isValidPointerPos ); \ - assert((x)->inhibitIdle ); \ - assert((x)->uninhibitIdle ); \ - assert((x)->wait ); \ - assert((x)->setWindowSize ); \ - assert((x)->setFullscreen ); \ - assert((x)->getFullscreen ); \ - assert((x)->minimize ); + DEBUG_ASSERT(!(x)->waitFrame == !(x)->stopWaitFrame); \ + DEBUG_ASSERT((x)->guestPointerUpdated); \ + DEBUG_ASSERT((x)->setPointer ); \ + DEBUG_ASSERT((x)->grabPointer ); \ + DEBUG_ASSERT((x)->ungrabPointer ); \ + DEBUG_ASSERT((x)->capturePointer ); \ + DEBUG_ASSERT((x)->uncapturePointer ); \ + DEBUG_ASSERT((x)->warpPointer ); \ + DEBUG_ASSERT((x)->realignPointer ); \ + DEBUG_ASSERT((x)->isValidPointerPos ); \ + DEBUG_ASSERT((x)->inhibitIdle ); \ + DEBUG_ASSERT((x)->uninhibitIdle ); \ + DEBUG_ASSERT((x)->wait ); \ + DEBUG_ASSERT((x)->setWindowSize ); \ + DEBUG_ASSERT((x)->setFullscreen ); \ + DEBUG_ASSERT((x)->getFullscreen ); \ + DEBUG_ASSERT((x)->minimize ); #endif diff --git a/client/include/interface/overlay.h b/client/include/interface/overlay.h index c41fd86e..66bf6a76 100644 --- a/client/include/interface/overlay.h +++ b/client/include/interface/overlay.h @@ -22,7 +22,6 @@ #define _H_I_OVERLAY_ #include -#include #include "common/types.h" @@ -64,9 +63,9 @@ struct LG_OverlayOps }; #define ASSERT_LG_OVERLAY_VALID(x) \ - assert((x)->name ); \ - assert((x)->init ); \ - assert((x)->free ); \ - assert((x)->render ); + DEBUG_ASSERT((x)->name ); \ + DEBUG_ASSERT((x)->init ); \ + DEBUG_ASSERT((x)->free ); \ + DEBUG_ASSERT((x)->render); #endif diff --git a/client/renderers/EGL/desktop_rects.c b/client/renderers/EGL/desktop_rects.c index 2e132453..27ace631 100644 --- a/client/renderers/EGL/desktop_rects.c +++ b/client/renderers/EGL/desktop_rects.c @@ -119,7 +119,7 @@ void egl_desktopRectsUpdate(EGL_DesktopRects * rects, const struct DamageRects * else { rects->count = data->count; - assert(rects->count <= rects->maxCount); + DEBUG_ASSERT(rects->count <= rects->maxCount); for (int i = 0; i < rects->count; ++i) rectToVertices(vertices + i * 8, data->rects + i); diff --git a/client/renderers/EGL/model.c b/client/renderers/EGL/model.c index 11b0a6b4..225533c9 100644 --- a/client/renderers/EGL/model.c +++ b/client/renderers/EGL/model.c @@ -28,7 +28,6 @@ #include #include #include -#include struct EGL_Model { diff --git a/client/renderers/EGL/texture.c b/client/renderers/EGL/texture.c index 72f48dd5..7b33d264 100644 --- a/client/renderers/EGL/texture.c +++ b/client/renderers/EGL/texture.c @@ -21,7 +21,6 @@ #include "texture.h" #include -#include #include #include "shader.h" #include "common/framebuffer.h" @@ -66,12 +65,12 @@ bool egl_textureInit(EGL_Texture ** texture_, EGLDisplay * display, break; case EGL_TEXTYPE_FRAMEBUFFER: - assert(streaming); + DEBUG_ASSERT(streaming); ops = &EGL_TextureFrameBuffer; break; case EGL_TEXTYPE_DMABUF: - assert(streaming); + DEBUG_ASSERT(streaming); ops = &EGL_TextureDMABUF; break; diff --git a/client/renderers/EGL/texture_buffer.c b/client/renderers/EGL/texture_buffer.c index eec31203..495fe0c4 100644 --- a/client/renderers/EGL/texture_buffer.c +++ b/client/renderers/EGL/texture_buffer.c @@ -23,7 +23,6 @@ #include "egldebug.h" #include -#include // forwards extern const EGL_TextureOps EGL_TextureBuffer; @@ -109,7 +108,7 @@ bool egl_texBufferSetup(EGL_Texture * texture, const EGL_TexSetup * setup) static bool egl_texBufferUpdate(EGL_Texture * texture, const EGL_TexUpdate * update) { TextureBuffer * this = UPCAST(TextureBuffer, texture); - assert(update->type == EGL_TEXTYPE_BUFFER); + DEBUG_ASSERT(update->type == EGL_TEXTYPE_BUFFER); glBindTexture(GL_TEXTURE_2D, this->tex[0]); glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->format.pitch); @@ -164,7 +163,7 @@ static bool egl_texBufferStreamUpdate(EGL_Texture * texture, const EGL_TexUpdate * update) { TextureBuffer * this = UPCAST(TextureBuffer, texture); - assert(update->type == EGL_TEXTYPE_BUFFER); + DEBUG_ASSERT(update->type == EGL_TEXTYPE_BUFFER); LG_LOCK(this->copyLock); memcpy(this->buf[this->bufIndex].map, update->buffer, diff --git a/client/renderers/EGL/texture_dmabuf.c b/client/renderers/EGL/texture_dmabuf.c index 0279bfd0..f753c006 100644 --- a/client/renderers/EGL/texture_dmabuf.c +++ b/client/renderers/EGL/texture_dmabuf.c @@ -21,8 +21,6 @@ #include "texture.h" #include "texture_buffer.h" -#include - #include "egl_dynprocs.h" #include "egldebug.h" @@ -101,7 +99,8 @@ static bool egl_texDMABUFUpdate(EGL_Texture * texture, { TextureBuffer * parent = UPCAST(TextureBuffer, texture); TexDMABUF * this = UPCAST(TexDMABUF , parent); - assert(update->type == EGL_TEXTYPE_DMABUF); + + DEBUG_ASSERT(update->type == EGL_TEXTYPE_DMABUF); EGLImage image = EGL_NO_IMAGE; diff --git a/client/renderers/EGL/texture_framebuffer.c b/client/renderers/EGL/texture_framebuffer.c index 05b92db5..5523e73b 100644 --- a/client/renderers/EGL/texture_framebuffer.c +++ b/client/renderers/EGL/texture_framebuffer.c @@ -20,8 +20,6 @@ #include "texture.h" -#include - #include "texture_buffer.h" #include "common/debug.h" #include "common/KVMFR.h" @@ -84,7 +82,7 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update) TextureBuffer * parent = UPCAST(TextureBuffer, texture); TexFB * this = UPCAST(TexFB , parent ); - assert(update->type == EGL_TEXTYPE_FRAMEBUFFER); + DEBUG_ASSERT(update->type == EGL_TEXTYPE_FRAMEBUFFER); LG_LOCK(parent->copyLock); diff --git a/client/src/app.c b/client/src/app.c index e50894c5..6054e835 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -804,7 +804,7 @@ int app_renderOverlay(struct Rect * rects, int maxRects) // It is an error to run out of rectangles, because we will not be able to // correctly calculate the damage of the next frame. - assert(written >= 0); + DEBUG_ASSERT(written >= 0); const int toAdd = max(written, overlay->lastRectCount); totalDamage |= toAdd > maxRects; diff --git a/client/src/ll.c b/client/src/ll.c index 6423e9c7..50675407 100644 --- a/client/src/ll.c +++ b/client/src/ll.c @@ -20,9 +20,9 @@ #include "ll.h" +#include "common/debug.h" #include "common/locking.h" #include -#include struct ll_item { @@ -53,7 +53,7 @@ struct ll * ll_new(void) void ll_free(struct ll * list) { // never free a list with items in it! - assert(!list->head); + DEBUG_ASSERT(!list->head); LG_LOCK_FREE(list->lock); free(list); diff --git a/client/src/main.c b/client/src/main.c index 44b4c285..6b62f1d9 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -854,7 +853,7 @@ static int lg_run(void) break; } - assert(g_state.ds); + DEBUG_ASSERT(g_state.ds); ASSERT_LG_DS_VALID(g_state.ds); if (g_params.jitRender)