[PATCH 2/2] wayland-server: Improve error messages for bad globals

Jasper St. Pierre jstpierre at mecheye.net
Tue Nov 12 18:44:37 PST 2013


A bug in Weston's toytoolkit gave me an hour of debugging headaches.
Improve the error messages that we send if a client requests an invalid
global, either by name or by version.
---
 src/wayland-server.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index d7c58b9..26fb84e 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -620,11 +620,15 @@ registry_bind(struct wl_client *client,
 		if (global->name == name)
 			break;
 
-	if (&global->link == &display->global_list ||
-	    global->version < version)
+	if (&global->link == &display->global_list)
 		wl_resource_post_error(resource,
 				       WL_DISPLAY_ERROR_INVALID_OBJECT,
-				       "invalid global %d", name);
+				       "invalid global %s (%d)", interface, name);
+	else if (global->version < version)
+		wl_resource_post_error(resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "invalid version for global %s (%d): have %d, wanted %d",
+				       interface, name, global->version, version);
 	else
 		global->bind(client, global->data, version, id);
 }
-- 
1.8.4.2



More information about the wayland-devel mailing list