ia64/xen-unstable

changeset 13216:ede2f5280810

[QEMU] Fix a number of signedness issues plus a typo in the version checking in vnc.c.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
author kaf24@localhost.localdomain
date Thu Dec 28 17:11:31 2006 +0000 (2006-12-28)
parents a138fabc2120
children f087c013cf12
files tools/ioemu/vnc.c tools/ioemu/vnchextile.h
line diff
     1.1 --- a/tools/ioemu/vnc.c	Thu Dec 28 17:09:34 2006 +0000
     1.2 +++ b/tools/ioemu/vnc.c	Thu Dec 28 17:11:31 2006 +0000
     1.3 @@ -54,12 +54,12 @@ typedef struct Buffer
     1.4  {
     1.5      size_t capacity;
     1.6      size_t offset;
     1.7 -    char *buffer;
     1.8 +    uint8_t *buffer;
     1.9  } Buffer;
    1.10  
    1.11  typedef struct VncState VncState;
    1.12  
    1.13 -typedef int VncReadEvent(VncState *vs, char *data, size_t len);
    1.14 +typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len);
    1.15  
    1.16  typedef void VncWritePixels(VncState *vs, void *data, int size);
    1.17  
    1.18 @@ -90,7 +90,7 @@ struct VncState
    1.19      uint64_t *update_row;	/* outstanding updates */
    1.20      int has_update;		/* there's outstanding updates in the
    1.21  				 * visible area */
    1.22 -    char *old_data;
    1.23 +    uint8_t *old_data;
    1.24      int depth; /* internal VNC frame buffer byte per pixel */
    1.25      int has_resize;
    1.26      int has_hextile;
    1.27 @@ -140,7 +140,7 @@ static void _vnc_update_client(void *opa
    1.28  static void vnc_update_client(void *opaque);
    1.29  static void vnc_client_read(void *opaque);
    1.30  static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h);
    1.31 -static int make_challenge(char *random, int size);
    1.32 +static int make_challenge(unsigned char *random, int size);
    1.33  static void set_seed(unsigned int *seedp);
    1.34  static void get_random(int len, unsigned char *buf);
    1.35  
    1.36 @@ -330,7 +330,7 @@ static void vnc_write_pixels_generic(Vnc
    1.37  static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)
    1.38  {
    1.39      int i;
    1.40 -    char *row;
    1.41 +    uint8_t *row;
    1.42  
    1.43      vnc_framebuffer_update(vs, x, y, w, h, 0);
    1.44  
    1.45 @@ -394,9 +394,9 @@ static void send_framebuffer_update(VncS
    1.46  static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
    1.47  {
    1.48      int src, dst;
    1.49 -    char *src_row;
    1.50 -    char *dst_row;
    1.51 -    char *old_row;
    1.52 +    uint8_t *src_row;
    1.53 +    uint8_t *dst_row;
    1.54 +    uint8_t *old_row;
    1.55      int y = 0;
    1.56      int pitch = ds->linesize;
    1.57      VncState *vs = ds->opaque;
    1.58 @@ -465,8 +465,8 @@ static void _vnc_update_client(void *opa
    1.59      VncState *vs = opaque;
    1.60      int64_t now;
    1.61      int y;
    1.62 -    char *row;
    1.63 -    char *old_row;
    1.64 +    uint8_t *row;
    1.65 +    uint8_t *old_row;
    1.66      uint64_t width_mask;
    1.67      int n_rectangles;
    1.68      int saved_offset;
    1.69 @@ -491,7 +491,7 @@ static void _vnc_update_client(void *opa
    1.70      for (y = 0; y < vs->ds->height; y++) {
    1.71  	if (vs->dirty_row[y] & width_mask) {
    1.72  	    int x;
    1.73 -	    char *ptr, *old_ptr;
    1.74 +	    uint8_t *ptr, *old_ptr;
    1.75  
    1.76  	    ptr = row;
    1.77  	    old_ptr = old_row;
    1.78 @@ -654,7 +654,7 @@ static int buffer_empty(Buffer *buffer)
    1.79      return buffer->offset == 0;
    1.80  }
    1.81  
    1.82 -static char *buffer_end(Buffer *buffer)
    1.83 +static uint8_t *buffer_end(Buffer *buffer)
    1.84  {
    1.85      return buffer->buffer + buffer->offset;
    1.86  }
    1.87 @@ -778,7 +778,7 @@ static void vnc_write_u32(VncState *vs, 
    1.88  
    1.89  static void vnc_write_u16(VncState *vs, uint16_t value)
    1.90  {
    1.91 -    char buf[2];
    1.92 +    uint8_t buf[2];
    1.93  
    1.94      buf[0] = (value >> 8) & 0xFF;
    1.95      buf[1] = value & 0xFF;
    1.96 @@ -788,7 +788,7 @@ static void vnc_write_u16(VncState *vs, 
    1.97  
    1.98  static void vnc_write_u8(VncState *vs, uint8_t value)
    1.99  {
   1.100 -    vnc_write(vs, (char *)&value, 1);
   1.101 +    vnc_write(vs, &value, 1);
   1.102  }
   1.103  
   1.104  static void vnc_flush(VncState *vs)
   1.105 @@ -797,23 +797,23 @@ static void vnc_flush(VncState *vs)
   1.106  	vnc_client_write(vs);
   1.107  }
   1.108  
   1.109 -static uint8_t read_u8(char *data, size_t offset)
   1.110 +static uint8_t read_u8(uint8_t *data, size_t offset)
   1.111  {
   1.112      return data[offset];
   1.113  }
   1.114  
   1.115 -static uint16_t read_u16(char *data, size_t offset)
   1.116 +static uint16_t read_u16(uint8_t *data, size_t offset)
   1.117  {
   1.118      return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
   1.119  }
   1.120  
   1.121 -static int32_t read_s32(char *data, size_t offset)
   1.122 +static int32_t read_s32(uint8_t *data, size_t offset)
   1.123  {
   1.124      return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
   1.125  		     (data[offset + 2] << 8) | data[offset + 3]);
   1.126  }
   1.127  
   1.128 -static uint32_t read_u32(char *data, size_t offset)
   1.129 +static uint32_t read_u32(uint8_t *data, size_t offset)
   1.130  {
   1.131      return ((data[offset] << 24) | (data[offset + 1] << 16) |
   1.132  	    (data[offset + 2] << 8) | data[offset + 3]);
   1.133 @@ -1115,11 +1115,10 @@ static void set_pixel_format(VncState *v
   1.134      vga_hw_update();
   1.135  }
   1.136  
   1.137 -static int protocol_client_msg(VncState *vs, char *data, size_t len)
   1.138 +static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
   1.139  {
   1.140      int i;
   1.141      uint16_t limit;
   1.142 -    int64_t now;
   1.143  
   1.144      switch (data[0]) {
   1.145      case 0:
   1.146 @@ -1188,7 +1187,7 @@ static int protocol_client_msg(VncState 
   1.147  		return 8 + v;
   1.148  	}
   1.149  
   1.150 -	client_cut_text(vs, read_u32(data, 4), data + 8);
   1.151 +	client_cut_text(vs, read_u32(data, 4), (char *)(data + 8));
   1.152  	break;
   1.153      default:
   1.154  	printf("Msg: %d\n", data[0]);
   1.155 @@ -1200,7 +1199,7 @@ static int protocol_client_msg(VncState 
   1.156      return 0;
   1.157  }
   1.158  
   1.159 -static int protocol_client_init(VncState *vs, char *data, size_t len)
   1.160 +static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
   1.161  {
   1.162      size_t l;
   1.163      char pad[3] = { 0, 0, 0 };
   1.164 @@ -1261,7 +1260,7 @@ static int protocol_client_init(VncState
   1.165      return 0;
   1.166  }
   1.167  
   1.168 -static int protocol_response(VncState *vs, char *client_response, size_t len)
   1.169 +static int protocol_response(VncState *vs, uint8_t *client_response, size_t len)
   1.170  {
   1.171      extern char vncpasswd[64];
   1.172      extern unsigned char challenge[AUTHCHALLENGESIZE];
   1.173 @@ -1299,7 +1298,7 @@ static int protocol_response(VncState *v
   1.174      return 0;
   1.175  }
   1.176  
   1.177 -static int protocol_version(VncState *vs, char *version, size_t len)
   1.178 +static int protocol_version(VncState *vs, uint8_t *version, size_t len)
   1.179  {
   1.180      extern char vncpasswd[64];
   1.181      extern unsigned char challenge[AUTHCHALLENGESIZE];
   1.182 @@ -1318,7 +1317,7 @@ static int protocol_version(VncState *vs
   1.183  
   1.184  
   1.185      support = 0;
   1.186 -    if (maj = 3) {
   1.187 +    if (maj == 3) {
   1.188  	if (min == 3 || min ==4) {
   1.189  	    support = 1;
   1.190  	}
   1.191 @@ -1468,7 +1467,7 @@ int vnc_start_viewer(int port)
   1.192  
   1.193  unsigned int seed;
   1.194  
   1.195 -static int make_challenge(char *random, int size)
   1.196 +static int make_challenge(unsigned char *random, int size)
   1.197  {
   1.198   
   1.199      set_seed(&seed);
     2.1 --- a/tools/ioemu/vnchextile.h	Thu Dec 28 17:09:34 2006 +0000
     2.2 +++ b/tools/ioemu/vnchextile.h	Thu Dec 28 17:11:31 2006 +0000
     2.3 @@ -13,7 +13,7 @@ static void CONCAT(send_hextile_tile_, N
     2.4                                               uint32_t *last_fg32,
     2.5                                               int *has_bg, int *has_fg)
     2.6  {
     2.7 -    char *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
     2.8 +    uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
     2.9      pixel_t *irow = (pixel_t *)row;
    2.10      int j, i;
    2.11      pixel_t *last_bg = (pixel_t *)last_bg32;
    2.12 @@ -119,7 +119,7 @@ static void CONCAT(send_hextile_tile_, N
    2.13  	for (j = 0; j < h; j++) {
    2.14  	    int has_color = 0;
    2.15  	    int min_x = -1;
    2.16 -	    pixel_t color;
    2.17 +	    pixel_t color = 0;
    2.18  
    2.19  	    for (i = 0; i < w; i++) {
    2.20  		if (!has_color) {