[PATCH xserver 01/15] dri3: annotate the dri3_screen_info data as const

Emil Velikov emil.l.velikov at gmail.com
Mon Apr 2 15:41:12 UTC 2018


From: Emil Velikov <emil.velikov at collabora.com>

dri3_screen_info is the user provide dispatch. Something that we do
not and should not change.

When using the _ptr typecast + const the compiler barfs at us
(rightfully so), so use the _rec one.

Fixes: 56313829886 ("dri3: Add DRI3 extension")
Cc: Keith Packard <keithp at keithp.com>
Cc: Adam Jackson <ajax at redhat.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Why do we have the explicit _rec and _ptr typecasts to begin with?

It reminds be of Pascal with it's infamous record ... from some 20
years ago.
---
 dri3/dri3.c                   |  2 +-
 dri3/dri3.h                   |  2 +-
 dri3/dri3_priv.h              |  2 +-
 dri3/dri3_screen.c            | 12 ++++++------
 glamor/glamor_egl.c           |  2 +-
 hw/xwayland/xwayland-glamor.c |  2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/dri3/dri3.c b/dri3/dri3.c
index 8ac0f3ae2..ba32facd7 100644
--- a/dri3/dri3.c
+++ b/dri3/dri3.c
@@ -45,7 +45,7 @@ dri3_close_screen(ScreenPtr screen)
 }
 
 Bool
-dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info)
+dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info)
 {
     dri3_screen_generation = serverGeneration;
 
diff --git a/dri3/dri3.h b/dri3/dri3.h
index 89ad13ad9..bd17522b0 100644
--- a/dri3/dri3.h
+++ b/dri3/dri3.h
@@ -104,7 +104,7 @@ typedef struct dri3_screen_info {
 } dri3_screen_info_rec, *dri3_screen_info_ptr;
 
 extern _X_EXPORT Bool
-dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info);
+dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info);
 
 extern _X_EXPORT int
 dri3_send_open_reply(ClientPtr client, int fd);
diff --git a/dri3/dri3_priv.h b/dri3/dri3_priv.h
index 8447680ba..cf6632ddf 100644
--- a/dri3/dri3_priv.h
+++ b/dri3/dri3_priv.h
@@ -49,7 +49,7 @@ typedef struct dri3_screen_priv {
     CARD32                      num_formats;
     dri3_dmabuf_format_ptr      formats;
 
-    dri3_screen_info_ptr        info;
+    const dri3_screen_info_rec *info;
 } dri3_screen_priv_rec, *dri3_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index df40f8281..0b045c413 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -31,7 +31,7 @@
 #include <randrstr.h>
 #include <drm_fourcc.h>
 
-static inline Bool has_open(dri3_screen_info_ptr info) {
+static inline Bool has_open(const dri3_screen_info_rec *info) {
     if (info == NULL)
         return FALSE;
 
@@ -43,7 +43,7 @@ int
 dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     int                         rc;
 
     if (!has_open(info))
@@ -68,7 +68,7 @@ dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
                      CARD8 depth, CARD8 bpp, CARD64 modifier)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     PixmapPtr                   pixmap;
 
     if (!info)
@@ -99,7 +99,7 @@ dri3_fds_from_pixmap(PixmapPtr pixmap, int *fds,
 {
     ScreenPtr                   screen = pixmap->drawable.pScreen;
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
 
     if (!info)
         return 0;
@@ -128,7 +128,7 @@ static int
 cache_formats_and_modifiers(ScreenPtr screen)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     CARD32                     *formats = NULL;
     CARD64                     *modifiers = NULL;
     int                         i;
@@ -188,7 +188,7 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
                              CARD64 **screen_modifiers)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     int                         i, j;
     int                         ret;
     CARD32                      num_drawable_mods;
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 4a550932a..5992b9279 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -755,7 +755,7 @@ glamor_dri3_open_client(ClientPtr client,
     return Success;
 }
 
-static dri3_screen_info_rec glamor_dri3_info = {
+static const dri3_screen_info_rec glamor_dri3_info = {
     .version = 2,
     .open_client = glamor_dri3_open_client,
     .pixmap_from_fds = glamor_pixmap_from_fds,
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 7e9815626..7f64483bf 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -815,7 +815,7 @@ glamor_get_modifiers(ScreenPtr screen, CARD32 format,
 }
 
 
-static dri3_screen_info_rec xwl_dri3_info = {
+static const dri3_screen_info_rec xwl_dri3_info = {
     .version = 2,
     .open = NULL,
     .pixmap_from_fds = glamor_pixmap_from_fds,
-- 
2.16.0



More information about the xorg-devel mailing list