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().

Signed-off-by: Bryce Harrington <[email protected]>
---
 src/compositor.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 230fd78..a2a03a7 100644
--- a/src/compositor.c
+++ b/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;
-- 
1.9.1

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to