compositor: Verify that the maximum number of outputs is not exceeded

output_id_pool is defined as a uint32_t, thus ffs() provides a range of
1-32 available id numbers.  When the 33rd output is enabled, Weston will
set the ID to (unsigned)(-1) and thus lead to some unexpected
behaviors.

I'm not sure what the best way to handle this error would be since this
is in an initialization routine, but at least let's document the
potential error condition with an assert().
dev
Bryce Harrington 9 years ago
parent 3f650b8c58
commit 18e4573cea
  1. 3
      src/compositor.c

@ -4303,6 +4303,9 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
{
struct wl_event_loop *loop;
/* Verify we haven't reached the limit of 32 available output IDs */
assert(ffs(~c->output_id_pool) > 0);
output->compositor = c;
output->x = x;
output->y = y;

Loading…
Cancel
Save