mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-01 07:16:07 -04:00
util: set errno in wl_map_insert_at()
And add errno checks in callers, where it seems to be necessary. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
This commit is contained in:
parent
03e8a1f84b
commit
884d5fe3ab
3 changed files with 18 additions and 9 deletions
|
|
@ -485,7 +485,10 @@ wl_proxy_create_for_id(struct wl_proxy *factory,
|
||||||
proxy->refcount = 1;
|
proxy->refcount = 1;
|
||||||
proxy->version = factory->version;
|
proxy->version = factory->version;
|
||||||
|
|
||||||
wl_map_insert_at(&display->objects, 0, id, proxy);
|
if (wl_map_insert_at(&display->objects, 0, id, proxy) == -1) {
|
||||||
|
free(proxy);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1843,9 +1843,11 @@ wl_resource_create(struct wl_client *client,
|
||||||
resource->dispatcher = NULL;
|
resource->dispatcher = NULL;
|
||||||
|
|
||||||
if (wl_map_insert_at(&client->objects, 0, id, resource) < 0) {
|
if (wl_map_insert_at(&client->objects, 0, id, resource) < 0) {
|
||||||
wl_resource_post_error(client->display_resource,
|
if (errno == EINVAL) {
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
wl_resource_post_error(client->display_resource,
|
||||||
"invalid new id %d", id);
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
|
"invalid new id %d", id);
|
||||||
|
}
|
||||||
free(resource);
|
free(resource);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -2240,10 +2242,12 @@ wl_client_add_resource(struct wl_client *client,
|
||||||
WL_MAP_ENTRY_LEGACY, resource);
|
WL_MAP_ENTRY_LEGACY, resource);
|
||||||
} else if (wl_map_insert_at(&client->objects, WL_MAP_ENTRY_LEGACY,
|
} else if (wl_map_insert_at(&client->objects, WL_MAP_ENTRY_LEGACY,
|
||||||
resource->object.id, resource) < 0) {
|
resource->object.id, resource) < 0) {
|
||||||
wl_resource_post_error(client->display_resource,
|
if (errno == EINVAL) {
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
wl_resource_post_error(client->display_resource,
|
||||||
"invalid new id %d",
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
resource->object.id);
|
"invalid new id %d",
|
||||||
|
resource->object.id);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,8 +239,10 @@ wl_map_insert_at(struct wl_map *map, uint32_t flags, uint32_t i, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
count = entries->size / sizeof *start;
|
count = entries->size / sizeof *start;
|
||||||
if (count < i)
|
if (count < i) {
|
||||||
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (count == i) {
|
if (count == i) {
|
||||||
if (!wl_array_add(entries, sizeof *start))
|
if (!wl_array_add(entries, sizeof *start))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue