[PATCH wayland 05/10] More consistent ID printing

Daniel Stone daniel at fooishbar.org
Mon Jul 23 11:54:42 PDT 2012


Use unsigned rather than signed for IDs, so they match up with what we
see in other prints.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/connection.c        |    4 ++--
 src/wayland-client.c    |   14 +++++++-------
 src/wayland-server.c    |   12 ++++++------
 tests/connection-test.c |    2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 4ba7f63..2733ac9 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -738,7 +738,7 @@ wl_connection_demarshal(struct wl_connection *connection,
 				 * destroyed client side */
 				*object = NULL;
 			} else if (*object == NULL && *p != 0) {
-				printf("unknown object (%d), message %s(%s)\n",
+				printf("unknown object (%u), message %s(%s)\n",
 				       *p, message->name, message->signature);
 				*object = NULL;
 				errno = EINVAL;
@@ -747,7 +747,7 @@ wl_connection_demarshal(struct wl_connection *connection,
 
 			if (*object != NULL && message->types[i-2] != NULL &&
 			    (*object)->interface != message->types[i-2]) {
-				printf("invalid object (%d), type (%s), "
+				printf("invalid object (%u), type (%s), "
 					"message %s(%s)\n",
 				       *p, (*object)->interface->name,
 				       message->name, message->signature);
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 7130cb7..631ec5a 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -203,14 +203,14 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
 		abort();
 	}
 
+	if (wl_debug)
+		wl_closure_print(closure, &proxy->object, true);
+
 	if (wl_closure_send(closure, proxy->display->connection)) {
 		fprintf(stderr, "Error sending request: %m\n");
 		abort();
 	}
 
-	if (wl_debug)
-		wl_closure_print(closure, &proxy->object, true);
-
 	wl_closure_destroy(closure);
 }
 
@@ -235,7 +235,7 @@ display_handle_error(void *data,
 		     struct wl_display *display, struct wl_object *object,
 		     uint32_t code, const char *message)
 {
-	fprintf(stderr, "%s@%d: error %d: %s\n",
+	fprintf(stderr, "%s@%u: error %d: %s\n",
 		object->interface->name, object->id, code, message);
 	abort();
 }
@@ -531,14 +531,14 @@ handle_event(struct wl_display *display,
 	closure = wl_connection_demarshal(display->connection, size,
 					  &display->objects, message);
 
+	if (wl_debug)
+		wl_closure_print(closure, &proxy->object, false);
+
 	if (closure == NULL || create_proxies(display, closure) < 0) {
 		fprintf(stderr, "Error demarshalling event\n");
 		abort();
 	}
 
-	if (wl_debug)
-		wl_closure_print(closure, &proxy->object, false);
-
 	wl_closure_invoke(closure, &proxy->object,
 			  proxy->object.implementation[opcode],
 			  proxy->user_data);
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 3dc8416..88e8433 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -243,7 +243,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 		if (resource == NULL) {
 			wl_resource_post_error(client->display_resource,
 					       WL_DISPLAY_ERROR_INVALID_OBJECT,
-					       "invalid object %d", p[0]);
+					       "invalid object %u", p[0]);
 			break;
 		}
 
@@ -251,7 +251,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 		if (opcode >= object->interface->method_count) {
 			wl_resource_post_error(client->display_resource,
 					       WL_DISPLAY_ERROR_INVALID_METHOD,
-					       "invalid method %d, object %s@%d",
+					       "invalid method %d, object %s@%u",
 					       opcode,
 					       object->interface->name,
 					       object->id);
@@ -263,10 +263,13 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 						  &client->objects, message);
 		len -= size;
 
+		if (wl_debug)
+			wl_closure_print(closure, object, false);
+
 		if (closure == NULL && errno == EINVAL) {
 			wl_resource_post_error(client->display_resource,
 					       WL_DISPLAY_ERROR_INVALID_METHOD,
-					       "invalid arguments for %s@%d.%s",
+					       "invalid arguments for %s@%u.%s",
 					       object->interface->name,
 					       object->id,
 					       message->name);
@@ -278,9 +281,6 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 
 		deref_new_objects(closure);
 
-		if (wl_debug)
-			wl_closure_print(closure, object, false);
-
 		wl_closure_invoke(closure, object,
 				  object->implementation[opcode], client);
 
diff --git a/tests/connection-test.c b/tests/connection-test.c
index a852c17..b6bcde1 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -236,7 +236,7 @@ TEST(connection_marshal)
 	marshal(&data, "n", 12, &object);
 	assert(data.buffer[2] == object.id);
 
-	marshal(&data, "n", 12, NULL);
+	marshal(&data, "?n", 12, NULL);
 	assert(data.buffer[2] == 0);
 
 	array.data = (void *) text;
-- 
1.7.10.4



More information about the wayland-devel mailing list