diff --git a/src/connection.c b/src/connection.c index 8870fd2d..fb6a4be8 100644 --- a/src/connection.c +++ b/src/connection.c @@ -75,7 +75,8 @@ struct wl_connection { static inline size_t size_pot(uint32_t size_bits) { - assert(size_bits < 8 * sizeof(size_t)); + if (!(size_bits < 8 * sizeof(size_t))) + wl_abort("Too many bits for size_t\n"); return ((size_t)1) << size_bits; } diff --git a/src/event-loop.c b/src/event-loop.c index 45222f71..f6392521 100644 --- a/src/event-loop.c +++ b/src/event-loop.c @@ -447,7 +447,8 @@ wl_timer_heap_disarm(struct wl_timer_heap *timers, struct wl_event_source_timer *last_end_evt; int old_source_idx; - assert(source->heap_idx >= 0); + if (!(source->heap_idx >= 0)) + wl_abort("Timer has already been disarmed\n"); old_source_idx = source->heap_idx; source->heap_idx = -1; @@ -476,7 +477,8 @@ wl_timer_heap_arm(struct wl_timer_heap *timers, struct wl_event_source_timer *source, struct timespec deadline) { - assert(source->heap_idx == -1); + if (!(source->heap_idx == -1)) + wl_abort("Timer is already armed\n"); source->deadline = deadline; timers->data[timers->active] = source; diff --git a/src/wayland-client.c b/src/wayland-client.c index 9cf27939..db5bcb58 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -235,13 +235,16 @@ wl_event_queue_init(struct wl_event_queue *queue, static void wl_proxy_unref(struct wl_proxy *proxy) { - assert(proxy->refcount > 0); + if (!(proxy->refcount > 0)) + wl_abort("Proxy requested for unref has no references\n"); if (--proxy->refcount > 0) return; /* If we get here, the client must have explicitly requested * deletion. */ - assert(proxy->flags & WL_PROXY_FLAG_DESTROYED); + if (!(proxy->flags & WL_PROXY_FLAG_DESTROYED)) + wl_abort("Proxy with no references not yet explicitly" + "destroyed\n"); free(proxy); } @@ -1172,7 +1175,8 @@ connect_to_socket(const char *name) "%s", name) + 1; } - assert(name_size > 0); + if (!(name_size > 0)) + wl_abort("Error assigning path name for socket connection\n"); if (name_size > (int)sizeof addr.sun_path) { if (!path_is_absolute) { wl_log("error: socket path \"%s/%s\" plus null terminator" @@ -2453,7 +2457,9 @@ wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue) wl_list_remove(&proxy->queue_link); if (queue) { - assert(proxy->display == queue->display); + if (!(proxy->display == queue->display)) + wl_abort("Proxy and queue point to different " + "wl_displays"); proxy->queue = queue; } else { proxy->queue = &proxy->display->default_queue; @@ -2581,7 +2587,8 @@ wl_proxy_wrapper_destroy(void *proxy_wrapper) wl_abort("Tried to destroy non-wrapper proxy with " "wl_proxy_wrapper_destroy\n"); - assert(wrapper->refcount == 1); + if (!(wrapper->refcount == 1)) + wl_abort("Expected proxy wrapper's refcount to be 1\n"); pthread_mutex_lock(&wrapper->display->mutex); diff --git a/src/wayland-server.c b/src/wayland-server.c index 2e185634..95f69e7f 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -1714,7 +1714,8 @@ wl_socket_init_for_display_name(struct wl_socket *s, const char *name) name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path, "%s%s%s", runtime_dir, separator, name) + 1; - assert(name_size > 0); + if (!(name_size > 0)) + wl_abort("Error assigning path name for socket address\n"); if (name_size > (int)sizeof s->addr.sun_path) { wl_log("error: socket path \"%s%s%s\" plus null terminator" " exceeds 108 bytes\n", runtime_dir, separator, name); diff --git a/src/wayland-shm.c b/src/wayland-shm.c index 0a11736a..70685e6c 100644 --- a/src/wayland-shm.c +++ b/src/wayland-shm.c @@ -144,12 +144,17 @@ shm_pool_unref(struct wl_shm_pool *pool, bool external) { if (external) { pool->external_refcount--; - assert(pool->external_refcount >= 0); + if (!(pool->external_refcount >= 0)) + wl_abort("Requested to unref an external reference to " + "pool but none found\n"); if (pool->external_refcount == 0) shm_pool_finish_resize(pool); } else { pool->internal_refcount--; - assert(pool->internal_refcount >= 0); + if (!(pool->internal_refcount >= 0)) + wl_abort("Requested to unref an internal reference to " + "pool but none found\n"); + } if (pool->internal_refcount + pool->external_refcount > 0) @@ -509,8 +514,9 @@ wl_shm_buffer_get_height(struct wl_shm_buffer *buffer) WL_EXPORT struct wl_shm_pool * wl_shm_buffer_ref_pool(struct wl_shm_buffer *buffer) { - assert(buffer->pool->internal_refcount + - buffer->pool->external_refcount); + if (!(buffer->pool->internal_refcount + + buffer->pool->external_refcount)) + wl_abort("Can't get reference to pool that has been freed\n"); buffer->pool->external_refcount++; return buffer->pool; @@ -658,8 +664,9 @@ wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer) pthread_setspecific(wl_shm_sigbus_data_key, sigbus_data); } - assert(sigbus_data->current_pool == NULL || - sigbus_data->current_pool == pool); + if (!(sigbus_data->current_pool == NULL || + sigbus_data->current_pool == pool)) + wl_abort("Incorrect pool passed for current thread\n"); sigbus_data->current_pool = pool; sigbus_data->access_count++; @@ -686,7 +693,9 @@ wl_shm_buffer_end_access(struct wl_shm_buffer *buffer) return; sigbus_data = pthread_getspecific(wl_shm_sigbus_data_key); - assert(sigbus_data && sigbus_data->access_count >= 1); + if (!(sigbus_data && sigbus_data->access_count >= 1)) + wl_abort("sigbus_data is NULL or wl_shm_buffer_begin_access " + "wasn't called before\n"); if (--sigbus_data->access_count == 0) { if (sigbus_data->fallback_mapping_used) {