[Xcb] Patch for compiler warnings in util-image

Bart Massey bart at cs.pdx.edu
Wed Aug 21 12:38:41 PDT 2013


This is fairly gratuitous, but, hey, compiler warnings. Could just
commit it, but would appreciate a review first. --Bart

>From c44f39f543e8f6978f1b81f81e3c9c3a10376c2f Mon Sep 17 00:00:00 2001
From: Bart Massey <bart at cs.pdx.edu>
Date: Wed, 21 Aug 2013 12:34:13 -0700
Subject: [PATCH] Fixed compiler warnings about non-C90 mixing of definitions
 and code.

I'm assuming that since the compiler had these warnings enabled, we want
this code to build on C90 systems...
---
 image/test_xcb_image_shm.c | 15 ++++++---------
 image/xcb_image.c          | 12 +++++++-----
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/image/test_xcb_image_shm.c b/image/test_xcb_image_shm.c
index 76f7f71..88a1f17 100644
--- a/image/test_xcb_image_shm.c
+++ b/image/test_xcb_image_shm.c
@@ -58,7 +58,10 @@ main (int argc, char *argv[])
   int              screen_nbr;
   xcb_generic_event_t *e;
   uint8_t format;
-
+  xcb_shm_segment_info_t shminfo;
+  xcb_shm_query_version_reply_t *rep;
+  xcb_image_t *img;
+
   /* Open the connexion to the X server and get the first screen */
   c = xcb_connect (NULL, &screen_nbr);
   screen = xcb_aux_get_screen (c, screen_nbr);
@@ -81,13 +84,8 @@ main (int argc, char *argv[])

   /* Shm test */
   printf ("shm test begin\n");
-  xcb_image_t *img = 0;
-  xcb_shm_query_version_reply_t *rep;
-  xcb_shm_segment_info_t shminfo;
+  rep = xcb_shm_query_version_reply (c, xcb_shm_query_version (c), NULL);

-  rep = xcb_shm_query_version_reply (c,
- xcb_shm_query_version (c),
- NULL);
   if (!rep || !rep->shared_pixmaps ||
       rep->major_version < 1 ||
       (rep->major_version == 1 && rep->minor_version == 0))
@@ -96,8 +94,7 @@ main (int argc, char *argv[])
   exit (0);
       }
   format = rep->pixmap_format;
-  img = xcb_image_create_native (c, W_W, W_H, format, depth,
-     0, ~0, 0);
+  img = xcb_image_create_native (c, W_W, W_H, format, depth, 0, ~0, 0);

   if (!img)
       {
diff --git a/image/xcb_image.c b/image/xcb_image.c
index 101aa4f..8ed5758 100644
--- a/image/xcb_image.c
+++ b/image/xcb_image.c
@@ -325,6 +325,12 @@ xcb_image_get (xcb_connection_t *  conn,
   case XCB_IMAGE_FORMAT_XY_PIXMAP:
       plane_mask &= xcb_mask(imrep->depth);
       if (plane_mask != xcb_mask(imrep->depth)) {
+  int            i;
+  uint32_t       rpm = plane_mask;
+  uint8_t *      src_plane = image->data;
+  uint8_t *      dst_plane;
+  uint32_t       size = image->height * image->stride;
+
   xcb_image_t *  tmp_image =
     xcb_image_create_native(conn, width, height, format,
     imrep->depth, 0, 0, 0);
@@ -334,11 +340,7 @@ xcb_image_get (xcb_connection_t *  conn,
       return 0;
   }

-  int            i;
-  uint32_t       rpm = plane_mask;
-  uint8_t *      src_plane = image->data;
-  uint8_t *      dst_plane = tmp_image->data;
-  uint32_t       size = image->height * image->stride;
+  dst_plane = tmp_image->data;

   if (tmp_image->bit_order == XCB_IMAGE_ORDER_MSB_FIRST)
       rpm = xcb_bit_reverse(plane_mask, imrep->depth);
-- 
1.8.4.rc2


More information about the Xcb mailing list