Merge branch 'build-errors' into 'master'

Fix build errors with -Werror and NDEBUG

See merge request wlroots/wlroots!4557
This commit is contained in:
John Lindgren 2024-12-08 12:39:03 +00:00
commit ccf98e44cd
9 changed files with 33 additions and 38 deletions

View file

@ -216,11 +216,10 @@ static void linux_dmabuf_feedback_v1_handle_tranche_formats(void *data,
return; return;
} }
size_t table_cap = feedback_data->format_table_size /
sizeof(struct wlr_wl_linux_dmabuf_v1_table_entry);
uint16_t *index_ptr; uint16_t *index_ptr;
wl_array_for_each(index_ptr, indices_arr) { 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 = const struct wlr_wl_linux_dmabuf_v1_table_entry *entry =
&feedback_data->format_table[*index_ptr]; &feedback_data->format_table[*index_ptr];
wlr_drm_format_set_add(&feedback_data->backend->linux_dmabuf_v1_formats, 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_output *sample_output = wl_container_of(listener, sample_output, frame);
struct sample_state *state = sample_output->state; struct sample_state *state = sample_output->state;
struct wlr_output *wlr_output = sample_output->output; struct wlr_output *wlr_output = sample_output->output;
struct wlr_renderer *renderer = state->renderer; assert(state->renderer);
assert(renderer);
struct wlr_output_state output_state; struct wlr_output_state output_state;
wlr_output_state_init(&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) { const struct wlr_render_texture_options *options) {
// make sure the texture source box does not try and sample outside of the // make sure the texture source box does not try and sample outside of the
// texture // 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 && assert(box->x >= 0 && box->y >= 0 &&
box->x + box->width <= options->texture->width && box->x + box->width <= options->texture->width &&
box->y + box->height <= options->texture->height); 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, const struct wlr_drm_format_set *display_formats,
struct wlr_drm_format *format, uint32_t fmt) { struct wlr_drm_format *format, uint32_t fmt) {
struct wlr_renderer *renderer = output->renderer; struct wlr_renderer *renderer = output->renderer;
struct wlr_allocator *allocator = output->allocator; assert(renderer != NULL && output->allocator != NULL);
assert(renderer != NULL && allocator != NULL);
const struct wlr_drm_format_set *render_formats = const struct wlr_drm_format_set *render_formats =
wlr_renderer_get_render_formats(renderer); wlr_renderer_get_render_formats(renderer);

View file

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

View file

@ -759,16 +759,15 @@ static void head_send_state(struct wlr_output_head_v1 *head,
} }
if (state & HEAD_STATE_MODE) { if (state & HEAD_STATE_MODE) {
bool found = false; struct wl_resource *mode_resource = NULL, *iter;
struct wl_resource *mode_resource; wl_resource_for_each(iter, &head->mode_resources) {
wl_resource_for_each(mode_resource, &head->mode_resources) { if (wl_resource_get_client(iter) == client &&
if (wl_resource_get_client(mode_resource) == client && mode_from_resource(iter) == head->state.mode) {
mode_from_resource(mode_resource) == head->state.mode) { mode_resource = iter;
found = true;
break; break;
} }
} }
assert(found); assert(mode_resource);
if (head->state.mode == NULL) { if (head->state.mode == NULL) {
// Fake a single output mode if output doesn't support modes // 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); 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) { const uint32_t *formats, size_t formats_len) {
assert(version <= SHM_VERSION);
// ARGB8888 and XRGB8888 must be supported per the wl_shm spec // ARGB8888 and XRGB8888 must be supported per the wl_shm spec
bool has_argb8888 = false, has_xrgb8888 = false; bool has_argb8888 = false, has_xrgb8888 = false;
for (size_t i = 0; i < formats_len; i++) { 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; 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)); struct wlr_shm *shm = calloc(1, sizeof(*shm));
if (shm == NULL) { 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) { static void xwm_dnd_send_drop(struct wlr_xwm *xwm, uint32_t time) {
struct wlr_drag *drag = xwm->drag; assert(xwm->drag != NULL);
assert(drag != NULL); assert(xwm->drag_focus != NULL);
struct wlr_xwayland_surface *dest = xwm->drag_focus;
assert(dest != NULL);
xcb_client_message_data_t data = { 0 }; xcb_client_message_data_t data = { 0 };
data.data32[0] = xwm->dnd_selection.window; 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) { static void xwm_dnd_send_leave(struct wlr_xwm *xwm) {
struct wlr_drag *drag = xwm->drag; assert(xwm->drag != NULL);
assert(drag != NULL); assert(xwm->drag_focus != NULL);
struct wlr_xwayland_surface *dest = xwm->drag_focus;
assert(dest != NULL);
xcb_client_message_data_t data = { 0 }; xcb_client_message_data_t data = { 0 };
data.data32[0] = xwm->dnd_selection.window; data.data32[0] = xwm->dnd_selection.window;

View file

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