[PATCH weston] window: avoid a gcc warning in buffer release handler
ppaalanen at gmail.com
ppaalanen at gmail.com
Wed May 22 00:20:05 PDT 2013
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Apparently some compilers complain about set but not used variables
'available' and 'bufs', but I don't get the warning. Still, separate the
debugging code from shm_surface_buffer_release(), so that we only
compute 'bufs' when it is printed. This should fix the warnings.
The debugging code now prints the shm_surface buffer state before and
after, instead of just after.
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
clients/window.c | 48 +++++++++++++++++++++++++++++++-----------------
1 file changed, 31 insertions(+), 17 deletions(-)
diff --git a/clients/window.c b/clients/window.c
index 40c0ef4..627f1e8 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -420,7 +420,9 @@ enum window_location {
static const cairo_user_data_key_t shm_surface_data_key;
-#if 0
+/* #define DEBUG */
+
+#ifdef DEBUG
static void
debug_print(void *proxy, int line, const char *func, const char *fmt, ...)
@@ -893,20 +895,43 @@ to_shm_surface(struct toysurface *base)
}
static void
+shm_surface_buffer_state_debug(struct shm_surface *surface, const char *msg)
+{
+#ifdef DEBUG
+ struct shm_surface_leaf *leaf;
+ char bufs[MAX_LEAVES + 1];
+ int i;
+
+ for (i = 0; i < MAX_LEAVES; i++) {
+ leaf = &surface->leaf[i];
+
+ if (leaf->busy)
+ bufs[i] = 'b';
+ else if (leaf->cairo_surface)
+ bufs[i] = 'a';
+ else
+ bufs[i] = ' ';
+ }
+
+ bufs[MAX_LEAVES] = '\0';
+ DBG_OBJ(surface->surface, "%s, leaves [%s]\n", msg, bufs);
+#endif
+}
+
+static void
shm_surface_buffer_release(void *data, struct wl_buffer *buffer)
{
struct shm_surface *surface = data;
struct shm_surface_leaf *leaf;
int i;
int free_found;
- int available = MAX_LEAVES;
- char bufs[MAX_LEAVES + 1];
+
+ shm_surface_buffer_state_debug(surface, "buffer_release before");
for (i = 0; i < MAX_LEAVES; i++) {
leaf = &surface->leaf[i];
if (leaf->data && leaf->data->buffer == buffer) {
leaf->busy = 0;
- available = i;
break;
}
}
@@ -917,27 +942,16 @@ shm_surface_buffer_release(void *data, struct wl_buffer *buffer)
for (i = 0; i < MAX_LEAVES; i++) {
leaf = &surface->leaf[i];
- if (leaf->busy)
- bufs[i] = 'b';
- else if (leaf->cairo_surface)
- bufs[i] = 'a';
- else
- bufs[i] = ' ';
-
if (!leaf->cairo_surface || leaf->busy)
continue;
if (!free_found)
free_found = 1;
- else {
+ else
shm_surface_leaf_release(leaf);
- bufs[i] = '*';
- }
}
- bufs[MAX_LEAVES] = '\0';
- DBG_OBJ(surface->surface, "leaf %d released, leaves [%s]\n",
- available, bufs);
+ shm_surface_buffer_state_debug(surface, "buffer_release after");
}
static const struct wl_buffer_listener shm_surface_buffer_listener = {
--
1.8.1.5
More information about the wayland-devel
mailing list