From: Seunghun Lee Date: Fri, 21 Oct 2022 05:41:52 +0000 (+0900) Subject: Use DS_ASSERT macro instead of assert() X-Git-Tag: accepted/tizen/unified/20230106.165106~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F283589%2F2;p=platform%2Fcore%2Fuifw%2Flibds.git Use DS_ASSERT macro instead of assert() Change-Id: Iecf32f4173556f50c913c50d58338062ae1daf24 --- diff --git a/examples/libinput-backend.c b/examples/libinput-backend.c index 592fbc3..19a21af 100644 --- a/examples/libinput-backend.c +++ b/examples/libinput-backend.c @@ -9,6 +9,8 @@ #include #include +#include "util.h" + #define UNUSED __attribute__((unused)) struct keyboard_device diff --git a/src/addon.c b/src/addon.c index e1858ff..0deac7a 100644 --- a/src/addon.c +++ b/src/addon.c @@ -1,5 +1,6 @@ #include +#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); diff --git a/src/allocator/shm.c b/src/allocator/shm.c index 96a0210..36f3709 100644 --- a/src/allocator/shm.c +++ b/src/allocator/shm.c @@ -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; } diff --git a/src/backend/libinput/backend.c b/src/backend/libinput/backend.c index 22c07e0..8b0c8fd 100644 --- a/src/backend/libinput/backend.c +++ b/src/backend/libinput/backend.c @@ -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; } diff --git a/src/backend/libinput/input.c b/src/backend/libinput/input.c index b6e943f..89ea635 100644 --- a/src/backend/libinput/input.c +++ b/src/backend/libinput/input.c @@ -1,6 +1,7 @@ #include #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; } diff --git a/src/backend/wayland/backend.c b/src/backend/wayland/backend.c index 300cb36..4c8c9c8 100644 --- a/src/backend/wayland/backend.c +++ b/src/backend/wayland/backend.c @@ -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; } diff --git a/src/backend/wayland/output.c b/src/backend/wayland/output.c index 50fd7c8..285f1ac 100644 --- a/src/backend/wayland/output.c +++ b/src/backend/wayland/output.c @@ -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; } diff --git a/src/backend/wayland/seat.c b/src/backend/wayland/seat.c index bec12ad..8376ebf 100644 --- a/src/backend/wayland/seat.c +++ b/src/backend/wayland/seat.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -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; } diff --git a/src/buffer.c b/src/buffer.c index 4571679..6d0650b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,9 +1,9 @@ -#include #include #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); diff --git a/src/client_buffer/shm_client_buffer.c b/src/client_buffer/shm_client_buffer.c index 73d97ea..0b31b7f 100644 --- a/src/client_buffer/shm_client_buffer.c +++ b/src/client_buffer/shm_client_buffer.c @@ -1,10 +1,10 @@ -#include #include #include #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); diff --git a/src/data_device/data_offer.c b/src/data_device/data_offer.c index e12f5ef..fc17b66 100644 --- a/src/data_device/data_offer.c +++ b/src/data_device/data_offer.c @@ -3,6 +3,7 @@ #include #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) diff --git a/src/data_device/data_source.c b/src/data_device/data_source.c index f18472a..6a18e3b 100644 --- a/src/data_device/data_source.c +++ b/src/data_device/data_source.c @@ -1,13 +1,13 @@ -#include #include +#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; diff --git a/src/data_device/data_source_client.c b/src/data_device/data_source_client.c index 60aafeb..b647e27 100644 --- a/src/data_device/data_source_client.c +++ b/src/data_device/data_source_client.c @@ -1,7 +1,7 @@ -#include #include #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); } diff --git a/src/data_device/drag.c b/src/data_device/drag.c index c13acb4..1500682 100644 --- a/src/data_device/drag.c +++ b/src/data_device/drag.c @@ -1,5 +1,6 @@ -#include #include + +#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; diff --git a/src/output.c b/src/output.c index 1e34c86..de48b37 100644 --- a/src/output.c +++ b/src/output.c @@ -1,10 +1,11 @@ -#include #include #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; diff --git a/src/region.c b/src/region.c index 52e62c7..61b0117 100644 --- a/src/region.c +++ b/src/region.c @@ -1,10 +1,10 @@ -#include #include #include #include #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, ®ion_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; } } diff --git a/src/seat/seat.c b/src/seat/seat.c index 7fd884a..ca9c2e9 100644 --- a/src/seat/seat.c +++ b/src/seat/seat.c @@ -1,12 +1,12 @@ #include "config.h" -#include #define _POSIX_C_SOURCE 200809L #include #include #include #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); } diff --git a/src/seat/seat_pointer.c b/src/seat/seat_pointer.c index f8fb169..fc18769 100644 --- a/src/seat/seat_pointer.c +++ b/src/seat/seat_pointer.c @@ -1,8 +1,8 @@ -#include #include #include #include +#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; diff --git a/src/shell_surface.c b/src/shell_surface.c index 73c498b..18e0056 100644 --- a/src/shell_surface.c +++ b/src/shell_surface.c @@ -1,9 +1,9 @@ -#include #include #include #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) { diff --git a/src/surface/subsurface.c b/src/surface/subsurface.c index 080513f..eafa38a 100644 --- a/src/surface/subsurface.c +++ b/src/surface/subsurface.c @@ -1,9 +1,9 @@ -#include #include #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; } diff --git a/src/surface/surface.c b/src/surface/surface.c index 4c5a853..f4f86f6 100644 --- a/src/surface/surface.c +++ b/src/surface/surface.c @@ -1,4 +1,3 @@ -#include #include #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; diff --git a/src/swapchain.c b/src/swapchain.c index 78a2ece..be2af23 100644 --- a/src/swapchain.c +++ b/src/swapchain.c @@ -1,10 +1,11 @@ -#include #include #include #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; diff --git a/src/xdg_shell/xdg_surface.c b/src/xdg_shell/xdg_surface.c index 35ca7a7..1b566a5 100644 --- a/src/xdg_shell/xdg_surface.c +++ b/src/xdg_shell/xdg_surface.c @@ -1,8 +1,8 @@ -#include #include #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); diff --git a/src/xdg_shell/xdg_toplevel.c b/src/xdg_shell/xdg_toplevel.c index cd24bbc..56bba06 100644 --- a/src/xdg_shell/xdg_toplevel.c +++ b/src/xdg_shell/xdg_toplevel.c @@ -1,7 +1,7 @@ -#include #include #include +#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) { diff --git a/src/xdg_shell_v6/xdg_surface_v6.c b/src/xdg_shell_v6/xdg_surface_v6.c index 487ad45..d098172 100644 --- a/src/xdg_shell_v6/xdg_surface_v6.c +++ b/src/xdg_shell_v6/xdg_surface_v6.c @@ -1,8 +1,8 @@ -#include #include #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); diff --git a/src/xdg_shell_v6/xdg_toplevel_v6.c b/src/xdg_shell_v6/xdg_toplevel_v6.c index 463b65a..91b12a0 100644 --- a/src/xdg_shell_v6/xdg_toplevel_v6.c +++ b/src/xdg_shell_v6/xdg_toplevel_v6.c @@ -1,7 +1,7 @@ -#include #include #include +#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) {