From 266c3e5c1e1099a6b20bfd5668e7d90729a3d470 Mon Sep 17 00:00:00 2001 From: oldosfan Date: Thu, 15 Sep 2022 07:04:20 +0000 Subject: [PATCH] Minor code pruning * dmabuf.c (struct _BufferParams): Prune unused code. * shm.c (CreateBuffer): Fix offset checks. * xdg_toplevel.c (SetAppId): Don't allow setting the app ID on a mapped surface. --- dmabuf.c | 3 --- shm.c | 10 ++++++---- xdg_toplevel.c | 5 +++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dmabuf.c b/dmabuf.c index 7b3878d..dc4d25c 100644 --- a/dmabuf.c +++ b/dmabuf.c @@ -102,9 +102,6 @@ struct _BufferParams /* The width and height of the buffer that will be created. */ int width, height; - /* The buffer ID that will be used to create the buffer. */ - uint32_t buffer_id; - /* The DRM format. */ uint32_t drm_format; }; diff --git a/shm.c b/shm.c index 6e5cf76..0ebf24e 100644 --- a/shm.c +++ b/shm.c @@ -263,17 +263,18 @@ CreateBuffer (struct wl_client *client, struct wl_resource *resource, if (!depth) { wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_FORMAT, - "The specified format is not supported"); + "the specified format is not supported"); return; } pool = wl_resource_get_user_data (resource); if (pool->size < offset || stride != width * 4 - || offset + stride * height > pool->size) + || offset + stride * height > pool->size + || offset < 0) { wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_STRIDE, - "Invalid offset or stride, or pool too small"); + "invalid offset or stride, or pool too small"); return; } @@ -288,7 +289,8 @@ CreateBuffer (struct wl_client *client, struct wl_resource *resource, { /* X doesn't support smaller drawables. */ wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_STRIDE, - "Invalid size, X server does not support zero-width drawables"); + "invalid size, this server does not support" + " zero-width drawables"); return; } diff --git a/xdg_toplevel.c b/xdg_toplevel.c index 664bb07..e58111e 100644 --- a/xdg_toplevel.c +++ b/xdg_toplevel.c @@ -1622,6 +1622,11 @@ SetAppId (struct wl_client *client, struct wl_resource *resource, if (!toplevel->role) return; + if (toplevel->state & StateIsMapped) + /* The toplevel is already mapped. Setting class hints in this + situation is not possible under X. */ + return; + class_hints.res_name = (char *) app_id; class_hints.res_class = (char *) app_id;