Fix build errors with -Werror and NDEBUG

To reproduce:

    meson setup build -Db_ndebug=true --werror
    meson compile -C build
This commit is contained in:
John Lindgren 2024-07-20 11:14:13 -04:00
parent 4666996b2a
commit 722f3eae42
9 changed files with 33 additions and 38 deletions

View file

@ -213,11 +213,10 @@ static void linux_dmabuf_feedback_v1_handle_tranche_formats(void *data,
return;
}
size_t table_cap = feedback_data->format_table_size /
sizeof(struct wlr_wl_linux_dmabuf_v1_table_entry);
uint16_t *index_ptr;
wl_array_for_each(index_ptr, indices_arr) {
assert(*index_ptr < table_cap);
assert(*index_ptr < feedback_data->format_table_size /
sizeof(struct wlr_wl_linux_dmabuf_v1_table_entry));
const struct wlr_wl_linux_dmabuf_v1_table_entry *entry =
&feedback_data->format_table[*index_ptr];
wlr_drm_format_set_add(&feedback_data->backend->linux_dmabuf_v1_formats,

View file

@ -96,8 +96,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
struct sample_output *sample_output = wl_container_of(listener, sample_output, frame);
struct sample_state *state = sample_output->state;
struct wlr_output *wlr_output = sample_output->output;
struct wlr_renderer *renderer = state->renderer;
assert(renderer);
assert(state->renderer);
struct wlr_output_state output_state;
wlr_output_state_init(&output_state);

View file

@ -18,8 +18,8 @@ void wlr_render_pass_add_texture(struct wlr_render_pass *render_pass,
const struct wlr_render_texture_options *options) {
// make sure the texture source box does not try and sample outside of the
// texture
if (!wlr_fbox_empty(&options->src_box)) {
const struct wlr_fbox *box = &options->src_box;
const struct wlr_fbox *box = &options->src_box;
if (!wlr_fbox_empty(box)) {
assert(box->x >= 0 && box->y >= 0 &&
box->x + box->width <= options->texture->width &&
box->y + box->height <= options->texture->height);

View file

@ -152,8 +152,7 @@ bool output_pick_format(struct wlr_output *output,
const struct wlr_drm_format_set *display_formats,
struct wlr_drm_format *format, uint32_t fmt) {
struct wlr_renderer *renderer = output->renderer;
struct wlr_allocator *allocator = output->allocator;
assert(renderer != NULL && allocator != NULL);
assert(renderer != NULL && output->allocator != NULL);
const struct wlr_drm_format_set *render_formats =
wlr_renderer_get_render_formats(renderer);

View file

@ -935,15 +935,14 @@ void wlr_surface_unlock_cached(struct wlr_surface *surface, uint32_t seq) {
return;
}
bool found = false;
struct wlr_surface_state *cached;
wl_list_for_each(cached, &surface->cached, cached_state_link) {
if (cached->seq == seq) {
found = true;
struct wlr_surface_state *cached = NULL, *iter;
wl_list_for_each(iter, &surface->cached, cached_state_link) {
if (iter->seq == seq) {
cached = iter;
break;
}
}
assert(found);
assert(cached);
assert(cached->cached_state_locks > 0);
cached->cached_state_locks--;
@ -1485,6 +1484,7 @@ void wlr_surface_synced_finish(struct wlr_surface_synced *synced) {
}
}
assert(found);
(void)found;
struct wlr_surface_state *cached;
wl_list_for_each(cached, &surface->cached, cached_state_link) {

View file

@ -760,16 +760,15 @@ static void head_send_state(struct wlr_output_head_v1 *head,
}
if (state & HEAD_STATE_MODE) {
bool found = false;
struct wl_resource *mode_resource;
wl_resource_for_each(mode_resource, &head->mode_resources) {
if (wl_resource_get_client(mode_resource) == client &&
mode_from_resource(mode_resource) == head->state.mode) {
found = true;
struct wl_resource *mode_resource = NULL, *iter;
wl_resource_for_each(iter, &head->mode_resources) {
if (wl_resource_get_client(iter) == client &&
mode_from_resource(iter) == head->state.mode) {
mode_resource = iter;
break;
}
}
assert(found);
assert(mode_resource);
if (head->state.mode == NULL) {
// Fake a single output mode if output doesn't support modes

View file

@ -495,10 +495,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
free(shm);
}
struct wlr_shm *wlr_shm_create(struct wl_display *display, uint32_t version,
static bool __attribute__((unused)) has_argb8888_and_xrgb8888(
const uint32_t *formats, size_t formats_len) {
assert(version <= SHM_VERSION);
// ARGB8888 and XRGB8888 must be supported per the wl_shm spec
bool has_argb8888 = false, has_xrgb8888 = false;
for (size_t i = 0; i < formats_len; i++) {
@ -511,7 +509,13 @@ struct wlr_shm *wlr_shm_create(struct wl_display *display, uint32_t version,
break;
}
}
assert(has_argb8888 && has_xrgb8888);
return has_argb8888 && has_xrgb8888;
}
struct wlr_shm *wlr_shm_create(struct wl_display *display, uint32_t version,
const uint32_t *formats, size_t formats_len) {
assert(version <= SHM_VERSION);
assert(has_argb8888_and_xrgb8888(formats, formats_len));
struct wlr_shm *shm = calloc(1, sizeof(*shm));
if (shm == NULL) {

View file

@ -120,10 +120,8 @@ static void xwm_dnd_send_position(struct wlr_xwm *xwm, uint32_t time, int16_t x,
}
static void xwm_dnd_send_drop(struct wlr_xwm *xwm, uint32_t time) {
struct wlr_drag *drag = xwm->drag;
assert(drag != NULL);
struct wlr_xwayland_surface *dest = xwm->drag_focus;
assert(dest != NULL);
assert(xwm->drag != NULL);
assert(xwm->drag_focus != NULL);
xcb_client_message_data_t data = { 0 };
data.data32[0] = xwm->dnd_selection.window;
@ -133,10 +131,8 @@ static void xwm_dnd_send_drop(struct wlr_xwm *xwm, uint32_t time) {
}
static void xwm_dnd_send_leave(struct wlr_xwm *xwm) {
struct wlr_drag *drag = xwm->drag;
assert(drag != NULL);
struct wlr_xwayland_surface *dest = xwm->drag_focus;
assert(dest != NULL);
assert(xwm->drag != NULL);
assert(xwm->drag_focus != NULL);
xcb_client_message_data_t data = { 0 };
data.data32[0] = xwm->dnd_selection.window;

View file

@ -264,15 +264,14 @@ xcb_void_cookie_t xwm_send_event_with_size(xcb_connection_t *c,
uint8_t propagate, xcb_window_t destination,
uint32_t event_mask, const void *event, uint32_t length)
{
if (length == 32) {
assert(length <= 32);
if (length >= 32) {
return xcb_send_event(c, propagate, destination, event_mask, event);
} else if (length < 32) {
} else {
char buf[32];
memcpy(buf, event, length);
memset(buf + length, 0, 32 - length);
return xcb_send_event(c, propagate, destination, event_mask, buf);
} else {
assert(false && "Event too long");
}
}