aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-09-13 12:30:30 +0200
committerPierre Ossman <ossman@cendio.se>2018-09-13 12:30:30 +0200
commit9c88e0dd266292b4dec7857f073b811137b6b30d (patch)
treee8ea29145c093e2f502a6f8ea15d466b62bce3de /common
parent07cbf841be9a8a50e0842213086114fdd2cbbc06 (diff)
downloadtigervnc-9c88e0dd266292b4dec7857f073b811137b6b30d.tar.gz
tigervnc-9c88e0dd266292b4dec7857f073b811137b6b30d.zip
Avoid compiler "use of uninitialised variable" warnings
The compiler isn't smart enough to figure all of these out, so restructure things a bit to avoid warnings.
Diffstat (limited to 'common')
-rw-r--r--common/rfb/CMsgReader.cxx65
1 files changed, 33 insertions, 32 deletions
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 0271936e..1d359d2c 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -210,18 +210,19 @@ void CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
if (width > maxCursorSize || height > maxCursorSize)
throw Exception("Too big cursor");
- rdr::U8 pr, pg, pb;
- rdr::U8 sr, sg, sb;
- int data_len = ((width+7)/8) * height;
- int mask_len = ((width+7)/8) * height;
- rdr::U8Array data(data_len);
- rdr::U8Array mask(mask_len);
-
- int x, y;
rdr::U8 buf[width*height*4];
- rdr::U8* out;
if (width * height > 0) {
+ rdr::U8 pr, pg, pb;
+ rdr::U8 sr, sg, sb;
+ int data_len = ((width+7)/8) * height;
+ int mask_len = ((width+7)/8) * height;
+ rdr::U8Array data(data_len);
+ rdr::U8Array mask(mask_len);
+
+ int x, y;
+ rdr::U8* out;
+
pr = is->readU8();
pg = is->readU8();
pb = is->readU8();
@@ -232,31 +233,31 @@ void CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
is->readBytes(data.buf, data_len);
is->readBytes(mask.buf, mask_len);
- }
- int maskBytesPerRow = (width+7)/8;
- out = buf;
- for (y = 0;y < height;y++) {
- for (x = 0;x < width;x++) {
- int byte = y * maskBytesPerRow + x / 8;
- int bit = 7 - x % 8;
-
- if (data.buf[byte] & (1 << bit)) {
- out[0] = pr;
- out[1] = pg;
- out[2] = pb;
- } else {
- out[0] = sr;
- out[1] = sg;
- out[2] = sb;
+ int maskBytesPerRow = (width+7)/8;
+ out = buf;
+ for (y = 0;y < height;y++) {
+ for (x = 0;x < width;x++) {
+ int byte = y * maskBytesPerRow + x / 8;
+ int bit = 7 - x % 8;
+
+ if (data.buf[byte] & (1 << bit)) {
+ out[0] = pr;
+ out[1] = pg;
+ out[2] = pb;
+ } else {
+ out[0] = sr;
+ out[1] = sg;
+ out[2] = sb;
+ }
+
+ if (mask.buf[byte] & (1 << bit))
+ out[3] = 255;
+ else
+ out[3] = 0;
+
+ out += 4;
}
-
- if (mask.buf[byte] & (1 << bit))
- out[3] = 255;
- else
- out[3] = 0;
-
- out += 4;
}
}