Use DS_ASSERT macro instead of assert() 89/283589/2
authorSeunghun Lee <shiin.lee@samsung.com>
Fri, 21 Oct 2022 05:41:52 +0000 (14:41 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 31 Oct 2022 05:05:35 +0000 (05:05 +0000)
Change-Id: Iecf32f4173556f50c913c50d58338062ae1daf24

26 files changed:
examples/libinput-backend.c
src/addon.c
src/allocator/shm.c
src/backend/libinput/backend.c
src/backend/libinput/input.c
src/backend/wayland/backend.c
src/backend/wayland/output.c
src/backend/wayland/seat.c
src/buffer.c
src/client_buffer/shm_client_buffer.c
src/data_device/data_offer.c
src/data_device/data_source.c
src/data_device/data_source_client.c
src/data_device/drag.c
src/output.c
src/region.c
src/seat/seat.c
src/seat/seat_pointer.c
src/shell_surface.c
src/surface/subsurface.c
src/surface/surface.c
src/swapchain.c
src/xdg_shell/xdg_surface.c
src/xdg_shell/xdg_toplevel.c
src/xdg_shell_v6/xdg_surface_v6.c
src/xdg_shell_v6/xdg_toplevel_v6.c

index 592fbc3..19a21af 100644 (file)
@@ -9,6 +9,8 @@
 #include <libds/keyboard.h>
 #include <libds/touch.h>
 
+#include "util.h"
+
 #define UNUSED   __attribute__((unused))
 
 struct keyboard_device
index e1858ff..0deac7a 100644 (file)
@@ -1,5 +1,6 @@
 #include <assert.h>
 
+#include "util.h"
 #include "addon.h"
 
 void
@@ -25,11 +26,10 @@ ds_addon_init(struct ds_addon *addon, struct ds_addon_set *set,
 {
     struct ds_addon *iter;
 
-    assert(owner && impl);
+    DS_ASSERT(owner && impl);
 
     wl_list_for_each(iter, &set->addons, link) {
-        if (iter->owner == addon->owner && iter->impl == addon->impl)
-            assert(0 && "Can't have two addons of the same type with the same owner");
+        DS_ASSERT(iter->owner == addon->owner && iter->impl == addon->impl);
     }
 
     wl_list_insert(&set->addons, &addon->link);
index 96a0210..36f3709 100644 (file)
@@ -47,7 +47,7 @@ ds_shm_allocator_create(void)
 static struct ds_shm_allocator *
 shm_allocator_from_allocator(struct ds_allocator *ds_allocator)
 {
-    assert(ds_allocator->iface == &shm_allocator_iface);
+    DS_ASSERT(ds_allocator->iface == &shm_allocator_iface);
     return (struct ds_shm_allocator *)ds_allocator;
 }
 
@@ -66,7 +66,7 @@ static const struct ds_buffer_interface shm_buffer_interface;
 static struct ds_shm_buffer *
 shm_buffer_from_buffer(struct ds_buffer *buffer)
 {
-    assert(buffer->iface == &shm_buffer_interface);
+    DS_ASSERT(buffer->iface == &shm_buffer_interface);
     return (struct ds_shm_buffer *)buffer;
 }
 
index 22c07e0..8b0c8fd 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "backend.h"
 
 static const struct ds_backend_interface libinput_backend_interface;
@@ -44,7 +45,7 @@ ds_libinput_backend_create(struct wl_display *display)
 WL_EXPORT struct ds_libinput_backend *
 libinput_backend_from_backend(struct ds_backend *backend)
 {
-    assert(backend->iface == &libinput_backend_interface);
+    DS_ASSERT(backend->iface == &libinput_backend_interface);
     return (struct ds_libinput_backend *)backend;
 }
 
index b6e943f..89ea635 100644 (file)
@@ -1,6 +1,7 @@
 #include <assert.h>
 
 #include "libds/log.h"
+#include "util.h"
 #include "backend.h"
 
 static const struct ds_input_device_interface input_device_iface;
@@ -14,7 +15,7 @@ ds_input_device_is_libinput(struct ds_input_device *ds_dev)
 static struct ds_libinput_input_device *
 get_libinput_input_device_from_input_device(struct ds_input_device *ds_dev)
 {
-    assert(ds_input_device_is_libinput(ds_dev));
+    DS_ASSERT(ds_input_device_is_libinput(ds_dev));
     return (struct ds_libinput_input_device *)ds_dev;
 }
 
index 300cb36..4c8c9c8 100644 (file)
@@ -9,6 +9,7 @@
 #include "libds/output.h"
 #include "xdg-shell-client-protocol.h"
 
+#include "util.h"
 #include "backend.h"
 
 static const struct ds_backend_interface wl_backend_interface;
@@ -78,7 +79,7 @@ err_server:
 struct ds_wl_backend *
 wl_backend_from_backend(struct ds_backend *backend)
 {
-    assert(backend->iface == &wl_backend_interface);
+    DS_ASSERT(backend->iface == &wl_backend_interface);
     return (struct ds_wl_backend *)backend;
 }
 
index 50fd7c8..285f1ac 100644 (file)
@@ -7,6 +7,7 @@
 #include "libds/output.h"
 #include "xdg-shell-client-protocol.h"
 
+#include "util.h"
 #include "output.h"
 #include "backend.h"
 
@@ -163,7 +164,7 @@ static void output_update_cursor(struct ds_wl_output *output)
 static struct ds_wl_output *
 wl_output_from_output(struct ds_output *ds_output)
 {
-    assert(ds_output->iface == &wl_output_iface);
+    DS_ASSERT(ds_output->iface == &wl_output_iface);
     return (struct ds_wl_output *)ds_output;
 }
 
index bec12ad..8376ebf 100644 (file)
@@ -1,4 +1,3 @@
-#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -196,7 +195,7 @@ ds_input_device_is_wl(struct ds_input_device *ds_dev)
 static struct ds_wl_input_device *
 get_wl_input_device_from_input_device(struct ds_input_device *ds_dev)
 {
-    assert(ds_input_device_is_wl(ds_dev));
+    DS_ASSERT(ds_input_device_is_wl(ds_dev));
     return (struct ds_wl_input_device *)ds_dev;
 }
 
@@ -246,7 +245,7 @@ static const struct ds_pointer_interface pointer_iface;
 static struct ds_wl_pointer *
 get_wl_pointer_from_pointer(struct ds_pointer *ds_pointer)
 {
-    assert(ds_pointer->iface == &pointer_iface);
+    DS_ASSERT(ds_pointer->iface == &pointer_iface);
     return (struct ds_wl_pointer *)ds_pointer;
 }
 
@@ -427,7 +426,7 @@ static const struct ds_keyboard_interface keyboard_iface;
 static struct ds_wl_keyboard *
 get_wl_keyboard_from_keyboard(struct ds_keyboard *ds_keyboard)
 {
-    assert(ds_keyboard->iface == &keyboard_iface);
+    DS_ASSERT(ds_keyboard->iface == &keyboard_iface);
     return (struct ds_wl_keyboard *)ds_keyboard;
 }
 
@@ -615,7 +614,7 @@ static const struct ds_touch_interface touch_iface;
 static struct ds_wl_touch *
 get_wl_touch_from_touch(struct ds_touch *ds_touch)
 {
-    assert(ds_touch->iface == &touch_iface);
+    DS_ASSERT(ds_touch->iface == &touch_iface);
     return (struct ds_wl_touch *)ds_touch;
 }
 
index 4571679..6d0650b 100644 (file)
@@ -1,9 +1,9 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
 #include "libds/interfaces/buffer.h"
 
+#include "util.h"
 #include "buffer.h"
 #include "client_buffer.h"
 
@@ -32,7 +32,7 @@ ds_buffer_from_resource(struct wl_resource *resource)
     struct ds_buffer *buffer;
     const struct ds_buffer_resource_interface *iface;
 
-    assert(resource && ds_resource_is_buffer(resource));
+    DS_ASSERT(resource && ds_resource_is_buffer(resource));
 
     if (wl_shm_buffer_get(resource) != NULL) {
         struct ds_shm_client_buffer *shm_client_buffer =
@@ -66,7 +66,7 @@ ds_buffer_from_resource(struct wl_resource *resource)
 WL_EXPORT void
 ds_buffer_drop(struct ds_buffer *buffer)
 {
-    assert(!buffer->dropped);
+    DS_ASSERT(!buffer->dropped);
     buffer->dropped = true;
     ds_dbg("Buffer(%p) dropped: n_locks(%zu)", buffer, buffer->n_locks);
     buffer_consider_destroy(buffer);
@@ -83,7 +83,7 @@ ds_buffer_lock(struct ds_buffer *buffer)
 WL_EXPORT void
 ds_buffer_unlock(struct ds_buffer *buffer)
 {
-    assert(buffer->n_locks > 0);
+    DS_ASSERT(buffer->n_locks > 0);
     buffer->n_locks--;
     ds_dbg("Buffer(%p) n_locks(%zu)", buffer, buffer->n_locks);
 
@@ -97,7 +97,7 @@ WL_EXPORT bool
 ds_buffer_begin_data_ptr_access(struct ds_buffer *buffer, uint32_t flags,
         void **data, uint32_t *format, size_t *stride)
 {
-    assert(!buffer->accessing_data_ptr);
+    DS_ASSERT(!buffer->accessing_data_ptr);
     if (!buffer->iface->begin_data_ptr_access)
         return false;
     if (!buffer->iface->begin_data_ptr_access(buffer,
@@ -110,7 +110,7 @@ ds_buffer_begin_data_ptr_access(struct ds_buffer *buffer, uint32_t flags,
 WL_EXPORT void
 ds_buffer_end_data_ptr_access(struct ds_buffer *buffer)
 {
-    assert(buffer->accessing_data_ptr);
+    DS_ASSERT(buffer->accessing_data_ptr);
     buffer->iface->end_data_ptr_access(buffer);
     buffer->accessing_data_ptr = false;
 }
@@ -153,9 +153,9 @@ ds_buffer_register_resource_interface(
 {
     const struct ds_buffer_resource_interface **iface_ptr;
 
-    assert(iface);
-    assert(iface->is_instance);
-    assert(iface->from_resource);
+    DS_ASSERT(iface);
+    DS_ASSERT(iface->is_instance);
+    DS_ASSERT(iface->from_resource);
 
     wl_array_for_each(iface_ptr, &buffer_resource_interfaces) {
         if (*iface_ptr == iface) {
@@ -189,7 +189,7 @@ buffer_consider_destroy(struct ds_buffer *buffer)
     if (!buffer->dropped || buffer->n_locks > 0)
         return;
 
-    assert(!buffer->accessing_data_ptr);
+    DS_ASSERT(!buffer->accessing_data_ptr);
 
     wl_signal_emit(&buffer->events.destroy, NULL);
     buffer->iface->destroy(buffer);
index 73d97ea..0b31b7f 100644 (file)
@@ -1,10 +1,10 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include <drm_fourcc.h>
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "pixel_format.h"
 #include "buffer.h"
 #include "client_buffer.h"
@@ -52,7 +52,7 @@ static const struct ds_buffer_interface shm_client_buffer_iface;
 static struct ds_shm_client_buffer *
 shm_client_buffer_from_buffer(struct ds_buffer *buffer)
 {
-    assert(buffer->iface == &shm_client_buffer_iface);
+    DS_ASSERT(buffer->iface == &shm_client_buffer_iface);
     return (struct ds_shm_client_buffer *)buffer;
 }
 
@@ -140,7 +140,7 @@ shm_client_buffer_create(struct wl_resource *resource)
     int32_t height;
 
     shm_buffer = wl_shm_buffer_get(resource);
-    assert(shm_buffer);
+    DS_ASSERT(shm_buffer);
 
     width = wl_shm_buffer_get_width(shm_buffer);
     height = wl_shm_buffer_get_height(shm_buffer);
index e12f5ef..fc17b66 100644 (file)
@@ -3,6 +3,7 @@
 #include <strings.h>
 
 #include "libds/log.h"
+#include "util.h"
 #include "data_device_private.h"
 
 static const struct wl_data_offer_interface data_offer_iface;
@@ -58,7 +59,7 @@ create_data_offer(struct wl_resource *device_resource,
             wl_list_insert(&data_device->drag_offers, &offer->link);
             break;
         default:
-            assert(0 && "cannot reach here");
+            DS_ASSERT_NOT_REACHED();
             break;
     }
 
@@ -86,7 +87,7 @@ data_offer_update_action(struct ds_data_offer *offer)
 {
     uint32_t action;
 
-    assert(offer->type == DS_DATA_OFFER_DRAG);
+    DS_ASSERT(offer->type == DS_DATA_OFFER_DRAG);
 
     action = data_offer_choose_action(offer);
     if (offer->source->current_dnd_action == action)
index f18472a..6a18e3b 100644 (file)
@@ -1,13 +1,13 @@
-#include <assert.h>
 #include <stdlib.h>
 
+#include "util.h"
 #include "data_device_private.h"
 
 void
 ds_data_source_init(struct ds_data_source *source,
         const struct ds_data_source_interface *iface)
 {
-    assert(iface->send);
+    DS_ASSERT(iface->send);
 
     source->iface = iface;
     source->actions = -1;
index 60aafeb..b647e27 100644 (file)
@@ -1,7 +1,7 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
+#include "util.h"
 #include "data_device_private.h"
 
 static const struct wl_data_source_interface wl_data_source_iface;
@@ -169,7 +169,7 @@ static const struct wl_data_source_interface wl_data_source_iface = {
 static struct ds_data_source_client *
 data_source_client_from_data_source(struct ds_data_source *ds_source)
 {
-    assert(ds_source->iface->accept == data_source_client_iface_accept);
+    DS_ASSERT(ds_source->iface->accept == data_source_client_iface_accept);
     return (struct ds_data_source_client *)ds_source;
 }
 
@@ -211,7 +211,7 @@ data_source_client_iface_dnd_drop(struct ds_data_source *ds_source)
     struct ds_data_source_client *source;
 
     source = data_source_client_from_data_source(ds_source);
-    assert(wl_resource_get_version(source->resource) >=
+    DS_ASSERT(wl_resource_get_version(source->resource) >=
             WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION);
     wl_data_source_send_dnd_drop_performed(source->resource);
 }
@@ -222,7 +222,7 @@ data_source_client_iface_dnd_finish(struct ds_data_source *ds_source)
     struct ds_data_source_client *source;
 
     source = data_source_client_from_data_source(ds_source);
-    assert(wl_resource_get_version(source->resource) >=
+    DS_ASSERT(wl_resource_get_version(source->resource) >=
             WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION);
     wl_data_source_send_dnd_finished(source->resource);
 }
@@ -234,7 +234,7 @@ data_source_client_iface_dnd_action(struct ds_data_source *ds_source,
     struct ds_data_source_client *source;
 
     source = data_source_client_from_data_source(ds_source);
-    assert(wl_resource_get_version(source->resource) >=
+    DS_ASSERT(wl_resource_get_version(source->resource) >=
             WL_DATA_SOURCE_ACTION_SINCE_VERSION);
     wl_data_source_send_action(source->resource, action);
 }
index c13acb4..1500682 100644 (file)
@@ -1,5 +1,6 @@
-#include <assert.h>
 #include <stdlib.h>
+
+#include "util.h"
 #include "data_device_private.h"
 
 static const struct ds_pointer_grab_interface drag_pointer_grab_iface;
@@ -501,7 +502,7 @@ static const struct ds_keyboard_grab_interface drag_keyboard_grab_iface = {
 static void
 drag_start(struct ds_drag *drag, uint32_t serial)
 {
-    assert(!drag->started);
+    DS_ASSERT(!drag->started);
     drag->started = true;
 
     ds_seat_keyboard_start_grab(drag->seat, &drag->keyboard_grab);
@@ -531,7 +532,7 @@ drag_drop(struct ds_drag *drag, uint32_t time)
     struct ds_data_device *data_device;
     struct wl_resource *resource;
 
-    assert(drag->focused_client);
+    DS_ASSERT(drag->focused_client);
 
     drag->dropped = true;
 
index 1e34c86..de48b37 100644 (file)
@@ -1,10 +1,11 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
 #include "libds/output.h"
 #include "libds/interfaces/output.h"
 
+#include "util.h"
+
 #define OUTPUT_VERSION 3
 
 static void output_handle_display_destroy(struct wl_listener *listener,
@@ -28,7 +29,7 @@ WL_EXPORT void
 ds_output_init(struct ds_output *output, struct ds_backend *backend,
         const struct ds_output_interface *iface, struct wl_display *display)
 {
-    assert(iface->commit);
+    DS_ASSERT(iface->commit);
 
     output->backend = backend;
     output->iface = iface;
index 52e62c7..61b0117 100644 (file)
@@ -1,10 +1,10 @@
-#include <assert.h>
 #include <stdlib.h>
 #include <math.h>
 #include <pixman.h>
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "region.h"
 
 static const struct wl_region_interface region_impl;
@@ -39,7 +39,7 @@ ds_region_add(struct wl_client *client, uint32_t version, uint32_t id)
 pixman_region32_t *
 ds_region_from_resource(struct wl_resource *resource)
 {
-    assert(wl_resource_instance_of(resource, &wl_region_interface,
+    DS_ASSERT(wl_resource_instance_of(resource, &wl_region_interface,
                 &region_impl));
     return wl_resource_get_user_data(resource);
 }
@@ -107,7 +107,7 @@ ds_region_transform(pixman_region32_t *dst, pixman_region32_t *src,
                 break;
             default:
                 ds_err("Unknown transform value(%d)", transform);
-                assert(0 && "Cannot reach here");
+                DS_ASSERT_NOT_REACHED();
                 break;
        }
     }
index 7fd884a..ca9c2e9 100644 (file)
@@ -1,12 +1,12 @@
 #include "config.h"
 
-#include <assert.h>
 #define _POSIX_C_SOURCE 200809L
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "libds/log.h"
+#include "util.h"
 #include "data_device.h"
 #include "seat_private.h"
 
@@ -162,7 +162,7 @@ ds_seat_client_for_wl_client(struct ds_seat *seat, struct wl_client *wl_client)
 WL_EXPORT struct ds_seat_client *
 ds_seat_client_from_resource(struct wl_resource *resource)
 {
-    assert(wl_resource_instance_of(resource, &wl_seat_interface, &seat_impl));
+    DS_ASSERT(wl_resource_instance_of(resource, &wl_seat_interface, &seat_impl));
     return wl_resource_get_user_data(resource);
 }
 
index f8fb169..fc18769 100644 (file)
@@ -1,8 +1,8 @@
-#include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <time.h>
 
+#include "util.h"
 #include "seat_private.h"
 
 static const struct ds_pointer_grab_interface default_pointer_grab_iface;
@@ -36,7 +36,7 @@ ds_seat_pointer_notify_enter(struct ds_seat *seat, struct ds_surface *surface,
 {
     struct ds_seat_pointer_grab *grab = seat->pointer.grab;
 
-    assert(surface);
+    DS_ASSERT(surface);
     grab->iface->enter(grab, surface, sx, sy);
 }
 
@@ -237,7 +237,7 @@ ds_seat_pointer_send_axis(struct ds_seat *seat, uint32_t time_msec,
         return;
 
     if (pointer->sent_axis_source) {
-        assert(pointer->cached_axis_source == source);
+        DS_ASSERT(pointer->cached_axis_source == source);
     }
     else {
         pointer->sent_axis_source = true;
index 73c498b..18e0056 100644 (file)
@@ -1,9 +1,9 @@
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "shell.h"
 
 static const struct wl_shell_surface_interface shell_surface_impl;
@@ -151,7 +151,7 @@ unmap_shell_surface(struct ds_shell_surface *shell_surface)
             // TODO
             break;
         case DS_SHELL_SURFACE_ROLE_NONE:
-            assert(false && "not reached");
+            DS_ASSERT_NOT_REACHED();
     }
 
     wl_list_for_each_safe(configure, tmp, &shell_surface->configure_list, link)
@@ -324,7 +324,7 @@ shell_surface_configure_destroy(struct ds_shell_surface_configure *configure)
 static void
 create_shell_surface_toplevel(struct ds_shell_surface *shell_surface)
 {
-    assert(shell_surface->toplevel == NULL);
+    DS_ASSERT(shell_surface->toplevel == NULL);
 
     shell_surface->toplevel = calloc(1, sizeof *shell_surface->toplevel);
     if (!shell_surface->toplevel) {
index 080513f..eafa38a 100644 (file)
@@ -1,9 +1,9 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
 #include "libds/surface.h"
 
+#include "util.h"
 #include "surface-private.h"
 
 static const struct wl_subsurface_interface subsurface_impl;
@@ -79,7 +79,7 @@ ds_surface_is_subsurface(struct ds_surface *surface)
 WL_EXPORT struct ds_subsurface *
 ds_subsurface_from_resource(struct wl_resource *resource)
 {
-    assert(wl_resource_instance_of(resource, &wl_subsurface_interface,
+    DS_ASSERT(wl_resource_instance_of(resource, &wl_subsurface_interface,
                 &subsurface_impl));
     return wl_resource_get_user_data(resource);
 }
@@ -87,7 +87,7 @@ ds_subsurface_from_resource(struct wl_resource *resource)
 struct ds_subsurface *
 ds_subsurface_from_ds_surface(struct ds_surface *surface)
 {
-    assert(ds_surface_is_subsurface(surface));
+    DS_ASSERT(ds_surface_is_subsurface(surface));
     return (struct ds_subsurface *)surface->role_data;
 }
 
index 4c5a853..f4f86f6 100644 (file)
@@ -1,4 +1,3 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
@@ -73,7 +72,7 @@ ds_surface_send_frame_done(struct ds_surface *surface,
 WL_EXPORT struct ds_surface *
 ds_surface_from_resource(struct wl_resource *resource)
 {
-    assert(wl_resource_instance_of(resource, &wl_surface_interface,
+    DS_ASSERT(wl_resource_instance_of(resource, &wl_surface_interface,
                 &surface_impl));
     return wl_resource_get_user_data(resource);
 }
@@ -83,7 +82,7 @@ ds_surface_set_role(struct ds_surface *surface,
         const struct ds_surface_role *role, void *role_data,
         struct wl_resource *error_resource, uint32_t error_code)
 {
-    assert(role != NULL);
+    DS_ASSERT(role != NULL);
 
     if (surface->role != NULL && surface->role != role) {
         ds_err("Cannot assign role %s to ds_surface(%p) "
@@ -155,7 +154,7 @@ ds_surface_take_viewport(struct ds_surface *surface)
 WL_EXPORT void
 ds_surface_viewport_release(struct ds_surface_viewport *vp_handle)
 {
-    assert(vp_handle->taken == true);
+    DS_ASSERT(vp_handle->taken == true);
     vp_handle->taken = false;
 }
 
@@ -165,8 +164,8 @@ ds_surface_viewport_set_source(struct ds_surface_viewport *vp_handle,
 {
     struct ds_surface *surface;
 
-    assert(vp_handle->taken == true);
-    assert(x >= 0 && y >= 0 && width > 0 && height > 0);
+    DS_ASSERT(vp_handle->taken == true);
+    DS_ASSERT(x >= 0 && y >= 0 && width > 0 && height > 0);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
     surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
@@ -182,7 +181,7 @@ ds_surface_viewport_unset_source(struct ds_surface_viewport *vp_handle)
 {
     struct ds_surface *surface;
 
-    assert(vp_handle->taken == true);
+    DS_ASSERT(vp_handle->taken == true);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
     surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
@@ -195,8 +194,8 @@ ds_surface_viewport_set_destination(struct ds_surface_viewport *vp_handle,
 {
     struct ds_surface *surface;
 
-    assert(vp_handle->taken == true);
-    assert(width > 0 && height > 0);
+    DS_ASSERT(vp_handle->taken == true);
+    DS_ASSERT(width > 0 && height > 0);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
     surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
@@ -210,7 +209,7 @@ ds_surface_viewport_unset_destination(struct ds_surface_viewport *vp_handle)
 {
     struct ds_surface *surface;
 
-    assert(vp_handle->taken == true);
+    DS_ASSERT(vp_handle->taken == true);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
     surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
index 78a2ece..be2af23 100644 (file)
@@ -1,10 +1,11 @@
-#include <assert.h>
 #include <stdbool.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
 #include "libds/allocator.h"
 
+#include "util.h"
+
 #define DS_SWAPCHAIN_CAP    4
 
 struct ds_swapchain_slot
@@ -120,7 +121,7 @@ ds_swapchain_set_buffer_submitted(struct ds_swapchain *swapchain,
     struct ds_swapchain_slot *slot;
     size_t i;
 
-    assert(buffer);
+    DS_ASSERT(buffer);
 
     if (!swapchain_has_buffer(swapchain, buffer))
         return;
@@ -175,8 +176,8 @@ static struct ds_buffer *
 swapchain_slot_acquire(struct ds_swapchain *swapchain, struct ds_swapchain_slot *slot,
         int *age)
 {
-    assert(!slot->acquired);
-    assert(slot->buffer);
+    DS_ASSERT(!slot->acquired);
+    DS_ASSERT(slot->buffer);
 
     slot->acquired = true;
 
index 35ca7a7..1b566a5 100644 (file)
@@ -1,8 +1,8 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "xdg_shell.h"
 
 static const struct xdg_surface_interface xdg_surface_impl;
@@ -130,7 +130,7 @@ unmap_xdg_surface(struct ds_xdg_surface *surface)
             // TODO
             break;
         case DS_XDG_SURFACE_ROLE_NONE:
-            assert(false && "not reached");
+            DS_ASSERT_NOT_REACHED();
     }
 
     wl_list_for_each_safe(configure, tmp, &surface->configure_list, link)
@@ -402,7 +402,7 @@ xdg_surface_handle_ack_configure(struct wl_client *client,
         case DS_XDG_SURFACE_ROLE_POPUP:
             break;
         default:
-            assert(0 && "not reached");
+            DS_ASSERT_NOT_REACHED();
             break;
     }
 
@@ -472,7 +472,7 @@ surface_send_configure(void *user_data)
 
     switch (surface->role) {
         case DS_XDG_SURFACE_ROLE_NONE:
-            assert(0 && "not reached");
+            DS_ASSERT_NOT_REACHED();
             break;
         case DS_XDG_SURFACE_ROLE_TOPLEVEL:
             send_xdg_toplevel_configure(surface, configure);
index cd24bbc..56bba06 100644 (file)
@@ -1,7 +1,7 @@
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include "util.h"
 #include "xdg_shell.h"
 
 static const struct ds_surface_role xdg_toplevel_surface_role =
@@ -17,7 +17,7 @@ static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource);
 WL_EXPORT uint32_t
 ds_xdg_toplevel_set_activated(struct ds_xdg_surface *surface, bool activated)
 {
-    assert(surface->role == DS_XDG_SURFACE_ROLE_TOPLEVEL);
+    DS_ASSERT(surface->role == DS_XDG_SURFACE_ROLE_TOPLEVEL);
     surface->toplevel->scheduled.activated = activated;
 
     return ds_xdg_surface_schedule_configure(surface);
@@ -37,7 +37,7 @@ create_xdg_toplevel(struct ds_xdg_surface *surface, uint32_t id)
         return;
     }
 
-    assert(surface->toplevel == NULL);
+    DS_ASSERT(surface->toplevel == NULL);
 
     surface->toplevel = calloc(1, sizeof *surface->toplevel);
     if (!surface->toplevel) {
index 487ad45..d098172 100644 (file)
@@ -1,8 +1,8 @@
-#include <assert.h>
 #include <stdlib.h>
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "xdg_shell_v6.h"
 
 static const struct zxdg_surface_v6_interface xdg_surface_v6_impl;
@@ -130,7 +130,7 @@ unmap_xdg_surface_v6(struct ds_xdg_surface_v6 *surface)
             // TODO
             break;
         case DS_XDG_SURFACE_V6_ROLE_NONE:
-            assert(false && "not reached");
+            DS_ASSERT_NOT_REACHED();
     }
 
     wl_list_for_each_safe(configure, tmp, &surface->configure_list, link)
@@ -408,7 +408,7 @@ xdg_surface_v6_handle_ack_configure(struct wl_client *client,
         case DS_XDG_SURFACE_V6_ROLE_POPUP:
             break;
         default:
-            assert(0 && "not reached");
+            DS_ASSERT_NOT_REACHED();
             break;
     }
 
@@ -478,7 +478,7 @@ surface_send_configure(void *user_data)
 
     switch (surface->role) {
         case DS_XDG_SURFACE_V6_ROLE_NONE:
-            assert(0 && "not reached");
+            DS_ASSERT_NOT_REACHED();
             break;
         case DS_XDG_SURFACE_V6_ROLE_TOPLEVEL:
             send_xdg_toplevel_v6_configure(surface, configure);
index 463b65a..91b12a0 100644 (file)
@@ -1,7 +1,7 @@
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include "util.h"
 #include "xdg_shell_v6.h"
 
 static const struct ds_surface_role xdg_toplevel_v6_surface_role =
@@ -28,7 +28,7 @@ create_xdg_toplevel_v6(struct ds_xdg_surface_v6 *surface, uint32_t id)
         return;
     }
 
-    assert(surface->toplevel == NULL);
+    DS_ASSERT(surface->toplevel == NULL);
 
     surface->toplevel = calloc(1, sizeof *surface->toplevel);
     if (!surface->toplevel) {