mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
server: Make error posting functions take a resource instead of a client
This commit is contained in:
parent
c640571c00
commit
25fddf65a8
3 changed files with 39 additions and 40 deletions
|
|
@ -109,9 +109,10 @@ wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
wl_client_post_error(struct wl_client *client, struct wl_object *object,
|
wl_resource_post_error(struct wl_resource *resource,
|
||||||
uint32_t code, const char *msg, ...)
|
uint32_t code, const char *msg, ...)
|
||||||
{
|
{
|
||||||
|
struct wl_client *client = resource->client;
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
|
@ -121,7 +122,7 @@ wl_client_post_error(struct wl_client *client, struct wl_object *object,
|
||||||
|
|
||||||
client->error = 1;
|
client->error = 1;
|
||||||
wl_resource_post_event(client->display_resource,
|
wl_resource_post_event(client->display_resource,
|
||||||
WL_DISPLAY_ERROR, object, code, buffer);
|
WL_DISPLAY_ERROR, resource, code, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -157,7 +158,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
|
|
||||||
resource = wl_map_lookup(&client->objects, p[0]);
|
resource = wl_map_lookup(&client->objects, p[0]);
|
||||||
if (resource == NULL) {
|
if (resource == NULL) {
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
"invalid object %d", p[0]);
|
"invalid object %d", p[0]);
|
||||||
break;
|
break;
|
||||||
|
|
@ -165,7 +166,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
|
|
||||||
object = &resource->object;
|
object = &resource->object;
|
||||||
if (opcode >= object->interface->method_count) {
|
if (opcode >= object->interface->method_count) {
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_DISPLAY_ERROR_INVALID_METHOD,
|
WL_DISPLAY_ERROR_INVALID_METHOD,
|
||||||
"invalid method %d, object %s@%d",
|
"invalid method %d, object %s@%d",
|
||||||
object->interface->name,
|
object->interface->name,
|
||||||
|
|
@ -179,7 +180,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
len -= size;
|
len -= size;
|
||||||
|
|
||||||
if (closure == NULL && errno == EINVAL) {
|
if (closure == NULL && errno == EINVAL) {
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_DISPLAY_ERROR_INVALID_METHOD,
|
WL_DISPLAY_ERROR_INVALID_METHOD,
|
||||||
"invalid arguments for %s@%d.%s",
|
"invalid arguments for %s@%d.%s",
|
||||||
object->interface->name,
|
object->interface->name,
|
||||||
|
|
@ -187,7 +188,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
message->name);
|
message->name);
|
||||||
break;
|
break;
|
||||||
} else if (closure == NULL && errno == ENOMEM) {
|
} else if (closure == NULL && errno == ENOMEM) {
|
||||||
wl_client_post_no_memory(client);
|
wl_resource_post_no_memory(resource);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,9 +289,9 @@ wl_client_add_resource(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
wl_client_post_no_memory(struct wl_client *client)
|
wl_resource_post_no_memory(struct wl_resource *resource)
|
||||||
{
|
{
|
||||||
wl_client_post_error(client, &client->display_resource->object,
|
wl_resource_post_error(resource->client->display_resource,
|
||||||
WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
|
WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -526,7 +527,7 @@ display_bind(struct wl_client *client,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (&global->link == &display->global_list)
|
if (&global->link == &display->global_list)
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
"invalid global %d", name);
|
"invalid global %d", name);
|
||||||
else
|
else
|
||||||
|
|
@ -826,7 +827,7 @@ wl_client_add_object(struct wl_client *client,
|
||||||
|
|
||||||
resource = malloc(sizeof *resource);
|
resource = malloc(sizeof *resource);
|
||||||
if (resource == NULL) {
|
if (resource == NULL) {
|
||||||
wl_client_post_no_memory(client);
|
wl_resource_post_no_memory(client->display_resource);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -839,7 +840,7 @@ wl_client_add_object(struct wl_client *client,
|
||||||
wl_list_init(&resource->destroy_listener_list);
|
wl_list_init(&resource->destroy_listener_list);
|
||||||
|
|
||||||
if (wl_map_insert_at(&client->objects, resource->object.id, resource) < 0) {
|
if (wl_map_insert_at(&client->objects, resource->object.id, resource) < 0) {
|
||||||
wl_client_post_no_memory(client);
|
wl_resource_post_no_memory(client->display_resource);
|
||||||
free(resource);
|
free(resource);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,6 @@ void wl_display_remove_global(struct wl_display *display,
|
||||||
|
|
||||||
struct wl_client *wl_client_create(struct wl_display *display, int fd);
|
struct wl_client *wl_client_create(struct wl_display *display, int fd);
|
||||||
void wl_client_destroy(struct wl_client *client);
|
void wl_client_destroy(struct wl_client *client);
|
||||||
void wl_client_post_error(struct wl_client *client, struct wl_object *object,
|
|
||||||
uint32_t code, const char *msg, ...);
|
|
||||||
void wl_client_post_no_memory(struct wl_client *client);
|
|
||||||
void wl_client_flush(struct wl_client *client);
|
void wl_client_flush(struct wl_client *client);
|
||||||
|
|
||||||
struct wl_resource *
|
struct wl_resource *
|
||||||
|
|
@ -221,6 +218,7 @@ void wl_resource_post_event(struct wl_resource *resource,
|
||||||
uint32_t opcode, ...);
|
uint32_t opcode, ...);
|
||||||
void wl_resource_post_error(struct wl_resource *resource,
|
void wl_resource_post_error(struct wl_resource *resource,
|
||||||
uint32_t code, const char *msg, ...);
|
uint32_t code, const char *msg, ...);
|
||||||
|
void wl_resource_post_no_memory(struct wl_resource *resource);
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_display_set_compositor(struct wl_display *display,
|
wl_display_set_compositor(struct wl_display *display,
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
||||||
case WL_SHM_FORMAT_XRGB32:
|
case WL_SHM_FORMAT_XRGB32:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_SHM_ERROR_INVALID_FORMAT,
|
WL_SHM_ERROR_INVALID_FORMAT,
|
||||||
"invalid format");
|
"invalid format");
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
@ -136,7 +136,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 0 || height < 0 || stride < width) {
|
if (width < 0 || height < 0 || stride < width) {
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_SHM_ERROR_INVALID_STRIDE,
|
WL_SHM_ERROR_INVALID_STRIDE,
|
||||||
"invalid width, height or stride (%dx%d, %u)",
|
"invalid width, height or stride (%dx%d, %u)",
|
||||||
width, height, stride);
|
width, height, stride);
|
||||||
|
|
@ -149,7 +149,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
if (data == MAP_FAILED) {
|
if (data == MAP_FAILED) {
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_resource_post_error(resource,
|
||||||
WL_SHM_ERROR_INVALID_FD,
|
WL_SHM_ERROR_INVALID_FD,
|
||||||
"failed mmap fd %d", fd);
|
"failed mmap fd %d", fd);
|
||||||
return;
|
return;
|
||||||
|
|
@ -159,7 +159,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
||||||
width, height, stride, format, data);
|
width, height, stride, format, data);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
munmap(data, stride * height);
|
munmap(data, stride * height);
|
||||||
wl_client_post_no_memory(client);
|
wl_resource_post_no_memory(resource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue