[PATCH] shm: provide actual error on mmap failed

Jonas Ådahl jadahl at gmail.com
Tue Feb 6 13:32:15 UTC 2018


On Mon, Feb 05, 2018 at 03:39:43PM +0100, Olivier Fourdan wrote:
> When an mmap() fails, a WL_SHM_ERROR_INVALID_FD is raised and the client
> is killed.
> 
> However, there is no indication of the actual system error that caused
> mmap() to fail, which makes such error harder to investigate.
> 
> Provide the actual error message that caused mmap() to fail.
> 
> Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>

Reviewed-by: Jonas Ådahl <jadahl at gmail.com>

> ---
>  src/wayland-shm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/wayland-shm.c b/src/wayland-shm.c
> index 8e2ef77..4191231 100644
> --- a/src/wayland-shm.c
> +++ b/src/wayland-shm.c
> @@ -281,7 +281,7 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
>  	if (pool->data == MAP_FAILED) {
>  		wl_resource_post_error(resource,
>  				       WL_SHM_ERROR_INVALID_FD,
> -				       "failed mmap fd %d", fd);
> +				       "failed mmap fd %d: %m", fd);
>  		goto err_free;
>  	}
>  	close(fd);
> -- 
> 2.14.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list