[Spice-devel] [PATCH x11spice v2 1/3] Use unsigned int/size_t for display width/height/buffer size

Brendan Shanks bshanks at codeweavers.com
Wed Jul 17 02:16:04 UTC 2019


Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
---
 src/display.c |  8 ++++----
 src/display.h | 14 +++++++-------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/display.c b/src/display.c
index 01e0e85..47f6bd7 100644
--- a/src/display.c
+++ b/src/display.c
@@ -59,7 +59,7 @@ static xcb_screen_t *screen_of_display(xcb_connection_t *c, int screen)
     return NULL;
 }
 
-static int bits_per_pixel(display_t *d)
+static unsigned int bits_per_pixel(display_t *d)
 {
     xcb_format_iterator_t fmt;
 
@@ -332,10 +332,10 @@ int display_open(display_t *d, session_t *session)
         overall.
 */
 
-shm_image_t *create_shm_image(display_t *d, int w, int h)
+shm_image_t *create_shm_image(display_t *d, unsigned int w, unsigned int h)
 {
     shm_image_t *shmi;
-    int imgsize;
+    size_t imgsize;
     xcb_void_cookie_t cookie;
     xcb_generic_error_t *error;
 
@@ -353,7 +353,7 @@ shm_image_t *create_shm_image(display_t *d, int w, int h)
     if (shmi->shmid != -1)
         shmi->shmaddr = shmat(shmi->shmid, 0, 0);
     if (shmi->shmid == -1 || shmi->shmaddr == (void *) -1) {
-        g_warning("Cannot get shared memory of size %d; errno %d", imgsize, errno);
+        g_warning("Cannot get shared memory of size %" G_GSIZE_FORMAT "; errno %d", imgsize, errno);
         free(shmi);
         return NULL;
     }
diff --git a/src/display.h b/src/display.h
index dc4254b..298ce5d 100644
--- a/src/display.h
+++ b/src/display.h
@@ -33,9 +33,9 @@ struct session_struct;
 **--------------------------------------------------------------------------*/
 typedef struct {
     int shmid;
-    int w;
-    int h;
-    int bytes_per_line;
+    unsigned int w;
+    unsigned int h;
+    unsigned int bytes_per_line;
     xcb_shm_seg_t shmseg;
     void *shmaddr;
     void *drawable_ptr;
@@ -44,9 +44,9 @@ typedef struct {
 typedef struct {
     xcb_connection_t *c;
     xcb_window_t root;
-    int width;
-    int height;
-    int depth;
+    unsigned int width;
+    unsigned int height;
+    unsigned int depth;
 
     const xcb_query_extension_reply_t *damage_ext;
     xcb_damage_damage_t damage;
@@ -75,7 +75,7 @@ void display_stop_event_thread(display_t *d);
 int display_find_changed_tiles(display_t *d, int row, int *tiles, int tiles_across);
 void display_copy_image_into_fullscreen(display_t *d, shm_image_t *shmi, int x, int y);
 
-shm_image_t *create_shm_image(display_t *d, int w, int h);
+shm_image_t *create_shm_image(display_t *d, unsigned int w, unsigned int h);
 int read_shm_image(display_t *d, shm_image_t *shmi, int x, int y);
 void destroy_shm_image(display_t *d, shm_image_t *shmi);
 
-- 
2.17.1



More information about the Spice-devel mailing list