wayland-drm: constify the callbacks struct, take 2
authorEmil Velikov <emil.velikov@collabora.com>
Wed, 27 Sep 2017 18:49:12 +0000 (19:49 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 13 Oct 2017 11:56:12 +0000 (12:56 +0100)
Now that wayland-drm (correctly) keeps a local copy of the callbacks,
this should not longer cause explosions.

After all the symbol is a local, constant data.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
src/egl/drivers/dri2/egl_dri2.c
src/egl/wayland/wayland-drm/wayland-drm.c
src/egl/wayland/wayland-drm/wayland-drm.h

index d5cdf32afa6d8d5fb24ddf9b8400a48f0fd6e278..77f09271f05b21235424143e4ec8a167a3352198 100644 (file)
@@ -2745,17 +2745,16 @@ dri2_wl_release_buffer(void *user_data, struct wl_drm_buffer *buffer)
    dri2_dpy->image->destroyImage(buffer->driver_buffer);
 }
 
-static struct wayland_drm_callbacks wl_drm_callbacks = {
-        .authenticate = NULL,
-        .reference_buffer = dri2_wl_reference_buffer,
-        .release_buffer = dri2_wl_release_buffer
-};
-
 static EGLBoolean
 dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
                              struct wl_display *wl_dpy)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   const struct wayland_drm_callbacks wl_drm_callbacks = {
+      .authenticate = (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate,
+      .reference_buffer = dri2_wl_reference_buffer,
+      .release_buffer = dri2_wl_release_buffer
+   };
    int flags = 0;
    uint64_t cap;
 
@@ -2764,9 +2763,6 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
    if (dri2_dpy->wl_server_drm)
            return EGL_FALSE;
 
-   wl_drm_callbacks.authenticate =
-      (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate;
-
    if (drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap) == 0 &&
        cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
        dri2_dpy->image->base.version >= 7 &&
index 0f0a2317c7e6ff842ee14f39a00d2802aa213df3..73dfba9600e7b96341601dfa2addf24f6c766106 100644 (file)
@@ -259,7 +259,7 @@ wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
-                 struct wayland_drm_callbacks *callbacks, void *user_data,
+                 const struct wayland_drm_callbacks *callbacks, void *user_data,
                  uint32_t flags)
 {
        struct wl_drm *drm;
index 77e8d27304245ad1ae2c71fb651f892e08554f0e..111383ff1d687419e47fd660590873cb0b42ac29 100644 (file)
@@ -34,7 +34,7 @@ wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
-                struct wayland_drm_callbacks *callbacks, void *user_data,
+                const struct wayland_drm_callbacks *callbacks, void *user_data,
                  uint32_t flags);
 
 void