[PATCH xserver 03/15] dri3: annotate fds/strides/offsets arrays as const

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


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

It makes it perfectly clear that we should not be modifying them.
Should help highlight issues like the one fixed with previous commit.

Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Cc: Daniel Stone <daniels at collabora.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Strictly speaking one should annotate everything but pixmap/screen as
const to be perfectly clear about in/out arguments. Yet again nobody
bothers annotating int arguments so meh for now ;-)
---
 dri3/dri3.h                   | 6 +++---
 dri3/dri3_priv.h              | 6 ++++--
 dri3/dri3_screen.c            | 4 ++--
 glamor/glamor.h               | 6 +++---
 glamor/glamor_egl.c           | 4 ++--
 hw/xwayland/xwayland-glamor.c | 8 ++++----
 6 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dri3/dri3.h b/dri3/dri3.h
index bd17522b0..fc76908e1 100644
--- a/dri3/dri3.h
+++ b/dri3/dri3.h
@@ -49,11 +49,11 @@ typedef PixmapPtr (*dri3_pixmap_from_fd_proc) (ScreenPtr screen,
 
 typedef PixmapPtr (*dri3_pixmap_from_fds_proc) (ScreenPtr screen,
                                                 CARD8 num_fds,
-                                                int *fds,
+                                                const int *fds,
                                                 CARD16 width,
                                                 CARD16 height,
-                                                CARD32 *strides,
-                                                CARD32 *offsets,
+                                                const CARD32 *strides,
+                                                const CARD32 *offsets,
                                                 CARD8 depth,
                                                 CARD8 bpp,
                                                 CARD64 modifier);
diff --git a/dri3/dri3_priv.h b/dri3/dri3_priv.h
index cf6632ddf..ea278049d 100644
--- a/dri3/dri3_priv.h
+++ b/dri3/dri3_priv.h
@@ -79,8 +79,10 @@ int
 dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd);
 
 int
-dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen, CARD8 num_fds, int *fds,
-                     CARD16 width, CARD16 height, CARD32 *strides, CARD32 *offsets,
+dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
+                     CARD8 num_fds, const int *fds,
+                     CARD16 width, CARD16 height,
+                     const CARD32 *strides, const CARD32 *offsets,
                      CARD8 depth, CARD8 bpp, CARD64 modifier);
 
 int
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 0b045c413..f5e87bc9e 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -62,9 +62,9 @@ dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
 
 int
 dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
-                     CARD8 num_fds, int *fds,
+                     CARD8 num_fds, const int *fds,
                      CARD16 width, CARD16 height,
-                     CARD32 *strides, CARD32 *offsets,
+                     const CARD32 *strides, const CARD32 *offsets,
                      CARD8 depth, CARD8 bpp, CARD64 modifier)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 7b5676226..ef10e5cda 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -264,11 +264,11 @@ extern _X_EXPORT struct gbm_bo *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
  * */
 extern _X_EXPORT PixmapPtr glamor_pixmap_from_fds(ScreenPtr screen,
                                                   CARD8 num_fds,
-                                                  int *fds,
+                                                  const int *fds,
                                                   CARD16 width,
                                                   CARD16 height,
-                                                  CARD32 *strides,
-                                                  CARD32 *offsets,
+                                                  const CARD32 *strides,
+                                                  const CARD32 *offsets,
                                                   CARD8 depth,
                                                   CARD8 bpp,
                                                   uint64_t modifier);
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 5992b9279..aeb21c162 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -476,9 +476,9 @@ gbm_format_for_depth(CARD8 depth)
 
 _X_EXPORT PixmapPtr
 glamor_pixmap_from_fds(ScreenPtr screen,
-                       CARD8 num_fds, int *fds,
+                       CARD8 num_fds, const int *fds,
                        CARD16 width, CARD16 height,
-                       CARD32 *strides, CARD32 *offsets,
+                       const CARD32 *strides, const CARD32 *offsets,
                        CARD8 depth, CARD8 bpp,
                        uint64_t modifier)
 {
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 6ba716263..339420e05 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -647,10 +647,10 @@ xwl_dri3_open_client(ClientPtr client,
 
 _X_EXPORT PixmapPtr
 glamor_pixmap_from_fds(ScreenPtr screen,
-                         CARD8 num_fds, int *fds,
-                         CARD16 width, CARD16 height,
-                         CARD32 *strides, CARD32 *offsets,
-                         CARD8 depth, CARD8 bpp, uint64_t modifier)
+                       CARD8 num_fds, const int *fds,
+                       CARD16 width, CARD16 height,
+                       const CARD32 *strides, const CARD32 *offsets,
+                       CARD8 depth, CARD8 bpp, uint64_t modifier)
 {
     struct xwl_screen *xwl_screen = xwl_screen_get(screen);
     struct gbm_bo *bo = NULL;
-- 
2.16.0



More information about the xorg-devel mailing list