From: Anthony Liguori <aliguori@linux.vnet.ibm.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] Fix compile warnings in vnc.c
Date: Wed, 20 Dec 2006 14:33:34 -0600 [thread overview]
Message-ID: <45899E1E.80405@linux.vnet.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 332 bytes --]
This patch fixes a number of signedness issues plus a typo in the
version checking in vnc.c.
I've tested a similar patch against my V2E tree but have only compile
tested against unstable.
Something similar has been in qemu CVS for some time now.
Regards,
Anthony Liguori
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
[-- Attachment #2: xen-vnc-warnings.diff --]
[-- Type: text/x-patch, Size: 7023 bytes --]
# HG changeset patch
# User anthony@rhesus
# Date 1166646668 21600
# Node ID b3cbce5fdff19fa5c2d9d54e6439cd0d9a511397
# Parent f80f1cc7f85e10ae163e1536637517e026f45358
Fix compile warnings in vnc.c
diff -r f80f1cc7f85e -r b3cbce5fdff1 tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Wed Dec 20 09:48:21 2006 +0000
+++ b/tools/ioemu/vnc.c Wed Dec 20 14:31:08 2006 -0600
@@ -54,12 +54,12 @@ typedef struct Buffer
{
size_t capacity;
size_t offset;
- char *buffer;
+ uint8_t *buffer;
} Buffer;
typedef struct VncState VncState;
-typedef int VncReadEvent(VncState *vs, char *data, size_t len);
+typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len);
typedef void VncWritePixels(VncState *vs, void *data, int size);
@@ -90,7 +90,7 @@ struct VncState
uint64_t *update_row; /* outstanding updates */
int has_update; /* there's outstanding updates in the
* visible area */
- char *old_data;
+ uint8_t *old_data;
int depth; /* internal VNC frame buffer byte per pixel */
int has_resize;
int has_hextile;
@@ -140,7 +140,7 @@ static void vnc_update_client(void *opaq
static void vnc_update_client(void *opaque);
static void vnc_client_read(void *opaque);
static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h);
-static int make_challenge(char *random, int size);
+static int make_challenge(unsigned char *random, int size);
static void set_seed(unsigned int *seedp);
static void get_random(int len, unsigned char *buf);
@@ -330,7 +330,7 @@ static void send_framebuffer_update_raw(
static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)
{
int i;
- char *row;
+ uint8_t *row;
vnc_framebuffer_update(vs, x, y, w, h, 0);
@@ -394,9 +394,9 @@ static void vnc_copy(DisplayState *ds, i
static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
{
int src, dst;
- char *src_row;
- char *dst_row;
- char *old_row;
+ uint8_t *src_row;
+ uint8_t *dst_row;
+ uint8_t *old_row;
int y = 0;
int pitch = ds->linesize;
VncState *vs = ds->opaque;
@@ -465,8 +465,8 @@ static void _vnc_update_client(void *opa
VncState *vs = opaque;
int64_t now;
int y;
- char *row;
- char *old_row;
+ uint8_t *row;
+ uint8_t *old_row;
uint64_t width_mask;
int n_rectangles;
int saved_offset;
@@ -491,7 +491,7 @@ static void _vnc_update_client(void *opa
for (y = 0; y < vs->ds->height; y++) {
if (vs->dirty_row[y] & width_mask) {
int x;
- char *ptr, *old_ptr;
+ uint8_t *ptr, *old_ptr;
ptr = row;
old_ptr = old_row;
@@ -654,7 +654,7 @@ static int buffer_empty(Buffer *buffer)
return buffer->offset == 0;
}
-static char *buffer_end(Buffer *buffer)
+static uint8_t *buffer_end(Buffer *buffer)
{
return buffer->buffer + buffer->offset;
}
@@ -778,7 +778,7 @@ static void vnc_write_u32(VncState *vs,
static void vnc_write_u16(VncState *vs, uint16_t value)
{
- char buf[2];
+ uint8_t buf[2];
buf[0] = (value >> 8) & 0xFF;
buf[1] = value & 0xFF;
@@ -788,7 +788,7 @@ static void vnc_write_u16(VncState *vs,
static void vnc_write_u8(VncState *vs, uint8_t value)
{
- vnc_write(vs, (char *)&value, 1);
+ vnc_write(vs, &value, 1);
}
static void vnc_flush(VncState *vs)
@@ -797,23 +797,23 @@ static void vnc_flush(VncState *vs)
vnc_client_write(vs);
}
-static uint8_t read_u8(char *data, size_t offset)
+static uint8_t read_u8(uint8_t *data, size_t offset)
{
return data[offset];
}
-static uint16_t read_u16(char *data, size_t offset)
+static uint16_t read_u16(uint8_t *data, size_t offset)
{
return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
}
-static int32_t read_s32(char *data, size_t offset)
+static int32_t read_s32(uint8_t *data, size_t offset)
{
return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]);
}
-static uint32_t read_u32(char *data, size_t offset)
+static uint32_t read_u32(uint8_t *data, size_t offset)
{
return ((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]);
@@ -1115,11 +1115,10 @@ static void set_pixel_format(VncState *v
vga_hw_update();
}
-static int protocol_client_msg(VncState *vs, char *data, size_t len)
+static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
{
int i;
uint16_t limit;
- int64_t now;
switch (data[0]) {
case 0:
@@ -1188,7 +1187,7 @@ static int protocol_client_msg(VncState
return 8 + v;
}
- client_cut_text(vs, read_u32(data, 4), data + 8);
+ client_cut_text(vs, read_u32(data, 4), (char *)(data + 8));
break;
default:
printf("Msg: %d\n", data[0]);
@@ -1200,7 +1199,7 @@ static int protocol_client_msg(VncState
return 0;
}
-static int protocol_client_init(VncState *vs, char *data, size_t len)
+static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
{
size_t l;
char pad[3] = { 0, 0, 0 };
@@ -1261,7 +1260,7 @@ static int protocol_client_init(VncState
return 0;
}
-static int protocol_response(VncState *vs, char *client_response, size_t len)
+static int protocol_response(VncState *vs, uint8_t *client_response, size_t len)
{
extern char vncpasswd[64];
extern unsigned char challenge[AUTHCHALLENGESIZE];
@@ -1299,7 +1298,7 @@ static int protocol_response(VncState *v
return 0;
}
-static int protocol_version(VncState *vs, char *version, size_t len)
+static int protocol_version(VncState *vs, uint8_t *version, size_t len)
{
extern char vncpasswd[64];
extern unsigned char challenge[AUTHCHALLENGESIZE];
@@ -1318,7 +1317,7 @@ static int protocol_version(VncState *vs
support = 0;
- if (maj = 3) {
+ if (maj == 3) {
if (min == 3 || min ==4) {
support = 1;
}
@@ -1468,7 +1467,7 @@ int vnc_start_viewer(int port)
unsigned int seed;
-static int make_challenge(char *random, int size)
+static int make_challenge(unsigned char *random, int size)
{
set_seed(&seed);
diff -r f80f1cc7f85e -r b3cbce5fdff1 tools/ioemu/vnchextile.h
--- a/tools/ioemu/vnchextile.h Wed Dec 20 09:48:21 2006 +0000
+++ b/tools/ioemu/vnchextile.h Wed Dec 20 14:31:08 2006 -0600
@@ -13,7 +13,7 @@ static void CONCAT(send_hextile_tile_, N
uint32_t *last_fg32,
int *has_bg, int *has_fg)
{
- char *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
+ uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
pixel_t *irow = (pixel_t *)row;
int j, i;
pixel_t *last_bg = (pixel_t *)last_bg32;
@@ -119,7 +119,7 @@ static void CONCAT(send_hextile_tile_, N
for (j = 0; j < h; j++) {
int has_color = 0;
int min_x = -1;
- pixel_t color;
+ pixel_t color = 0;
for (i = 0; i < w; i++) {
if (!has_color) {
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2006-12-20 20:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45899E1E.80405@linux.vnet.ibm.com \
--to=aliguori@linux.vnet.ibm.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.