mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-12 13:29:55 -05:00
connection: Use wl_log to report errors
In some cases, like Xwayland, stdout and stderr are redirected to /dev/null, losing us valuable information, while wl_log can be overridden, allowing us to send it to a log file instead. This can help debugging immensely.
This commit is contained in:
parent
859b3e41f5
commit
52a77fca57
1 changed files with 18 additions and 18 deletions
|
|
@ -512,7 +512,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
|
||||||
|
|
||||||
count = arg_count_for_signature(message->signature);
|
count = arg_count_for_signature(message->signature);
|
||||||
if (count > WL_CLOSURE_MAX_ARGS) {
|
if (count > WL_CLOSURE_MAX_ARGS) {
|
||||||
printf("too many args (%d)\n", count);
|
wl_log("too many args (%d)\n", count);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -557,13 +557,13 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
|
||||||
fd = args[i].h;
|
fd = args[i].h;
|
||||||
dup_fd = wl_os_dupfd_cloexec(fd, 0);
|
dup_fd = wl_os_dupfd_cloexec(fd, 0);
|
||||||
if (dup_fd < 0) {
|
if (dup_fd < 0) {
|
||||||
fprintf(stderr, "dup failed: %m");
|
wl_log("dup failed: %m");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
closure->args[i].h = dup_fd;
|
closure->args[i].h = dup_fd;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "unhandled format code: '%c'\n",
|
wl_log("unhandled format code: '%c'\n",
|
||||||
arg.type);
|
arg.type);
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
|
|
@ -615,7 +615,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
|
|
||||||
count = arg_count_for_signature(message->signature);
|
count = arg_count_for_signature(message->signature);
|
||||||
if (count > WL_CLOSURE_MAX_ARGS) {
|
if (count > WL_CLOSURE_MAX_ARGS) {
|
||||||
printf("too many args (%d)\n", count);
|
wl_log("too many args (%d)\n", count);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
wl_connection_consume(connection, size);
|
wl_connection_consume(connection, size);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -642,7 +642,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
signature = get_next_argument(signature, &arg);
|
signature = get_next_argument(signature, &arg);
|
||||||
|
|
||||||
if (arg.type != 'h' && p + 1 > end) {
|
if (arg.type != 'h' && p + 1 > end) {
|
||||||
printf("message too short, "
|
wl_log("message too short, "
|
||||||
"object (%d), message %s(%s)\n",
|
"object (%d), message %s(%s)\n",
|
||||||
*p, message->name, message->signature);
|
*p, message->name, message->signature);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -669,7 +669,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
|
|
||||||
next = p + DIV_ROUNDUP(length, sizeof *p);
|
next = p + DIV_ROUNDUP(length, sizeof *p);
|
||||||
if (next > end) {
|
if (next > end) {
|
||||||
printf("message too short, "
|
wl_log("message too short, "
|
||||||
"object (%d), message %s(%s)\n",
|
"object (%d), message %s(%s)\n",
|
||||||
closure->sender_id, message->name,
|
closure->sender_id, message->name,
|
||||||
message->signature);
|
message->signature);
|
||||||
|
|
@ -680,7 +680,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
s = (char *) p;
|
s = (char *) p;
|
||||||
|
|
||||||
if (length > 0 && s[length - 1] != '\0') {
|
if (length > 0 && s[length - 1] != '\0') {
|
||||||
printf("string not nul-terminated, "
|
wl_log("string not nul-terminated, "
|
||||||
"message %s(%s)\n",
|
"message %s(%s)\n",
|
||||||
message->name, message->signature);
|
message->name, message->signature);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -695,7 +695,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
closure->args[i].n = id;
|
closure->args[i].n = id;
|
||||||
|
|
||||||
if (id == 0 && !arg.nullable) {
|
if (id == 0 && !arg.nullable) {
|
||||||
printf("NULL object received on non-nullable "
|
wl_log("NULL object received on non-nullable "
|
||||||
"type, message %s(%s)\n", message->name,
|
"type, message %s(%s)\n", message->name,
|
||||||
message->signature);
|
message->signature);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -707,7 +707,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
closure->args[i].n = id;
|
closure->args[i].n = id;
|
||||||
|
|
||||||
if (id == 0 && !arg.nullable) {
|
if (id == 0 && !arg.nullable) {
|
||||||
printf("NULL new ID received on non-nullable "
|
wl_log("NULL new ID received on non-nullable "
|
||||||
"type, message %s(%s)\n", message->name,
|
"type, message %s(%s)\n", message->name,
|
||||||
message->signature);
|
message->signature);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -715,7 +715,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_map_reserve_new(objects, id) < 0) {
|
if (wl_map_reserve_new(objects, id) < 0) {
|
||||||
printf("not a valid new object id (%d), "
|
wl_log("not a valid new object id (%d), "
|
||||||
"message %s(%s)\n",
|
"message %s(%s)\n",
|
||||||
id, message->name, message->signature);
|
id, message->name, message->signature);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -728,7 +728,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
|
|
||||||
next = p + DIV_ROUNDUP(length, sizeof *p);
|
next = p + DIV_ROUNDUP(length, sizeof *p);
|
||||||
if (next > end) {
|
if (next > end) {
|
||||||
printf("message too short, "
|
wl_log("message too short, "
|
||||||
"object (%d), message %s(%s)\n",
|
"object (%d), message %s(%s)\n",
|
||||||
closure->sender_id, message->name,
|
closure->sender_id, message->name,
|
||||||
message->signature);
|
message->signature);
|
||||||
|
|
@ -745,7 +745,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
if (connection->fds_in.tail == connection->fds_in.head) {
|
if (connection->fds_in.tail == connection->fds_in.head) {
|
||||||
printf("file descriptor expected, "
|
wl_log("file descriptor expected, "
|
||||||
"object (%d), message %s(%s)\n",
|
"object (%d), message %s(%s)\n",
|
||||||
closure->sender_id, message->name,
|
closure->sender_id, message->name,
|
||||||
message->signature);
|
message->signature);
|
||||||
|
|
@ -758,7 +758,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
closure->args[i].h = fd;
|
closure->args[i].h = fd;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("unknown type\n");
|
wl_log("unknown type\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -817,7 +817,7 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
|
||||||
* destroyed client side */
|
* destroyed client side */
|
||||||
object = NULL;
|
object = NULL;
|
||||||
} else if (object == NULL && id != 0) {
|
} else if (object == NULL && id != 0) {
|
||||||
printf("unknown object (%u), message %s(%s)\n",
|
wl_log("unknown object (%u), message %s(%s)\n",
|
||||||
id, message->name, message->signature);
|
id, message->name, message->signature);
|
||||||
object = NULL;
|
object = NULL;
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -827,7 +827,7 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
|
||||||
if (object != NULL && message->types[i] != NULL &&
|
if (object != NULL && message->types[i] != NULL &&
|
||||||
!wl_interface_equal((object)->interface,
|
!wl_interface_equal((object)->interface,
|
||||||
message->types[i])) {
|
message->types[i])) {
|
||||||
printf("invalid object (%u), type (%s), "
|
wl_log("invalid object (%u), type (%s), "
|
||||||
"message %s(%s)\n",
|
"message %s(%s)\n",
|
||||||
id, (object)->interface->name,
|
id, (object)->interface->name,
|
||||||
message->name, message->signature);
|
message->name, message->signature);
|
||||||
|
|
@ -893,7 +893,7 @@ convert_arguments_to_ffi(const char *signature, uint32_t flags,
|
||||||
ffi_args[i] = &args[i].h;
|
ffi_args[i] = &args[i].h;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("unknown type\n");
|
wl_log("unknown type\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -953,7 +953,7 @@ copy_fds_to_connection(struct wl_closure *closure,
|
||||||
|
|
||||||
fd = closure->args[i].h;
|
fd = closure->args[i].h;
|
||||||
if (wl_connection_put_fd(connection, fd)) {
|
if (wl_connection_put_fd(connection, fd)) {
|
||||||
fprintf(stderr, "request could not be marshaled: "
|
wl_log("request could not be marshaled: "
|
||||||
"can't send file descriptor");
|
"can't send file descriptor");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue