From d8b901a7e16417ecc503838bb12958fa15ab0d2b Mon Sep 17 00:00:00 2001 From: bladeoner Date: Thu, 6 Dec 2018 10:38:11 +0100 Subject: [PATCH] Backport Fix uninitialized warning and aliased pointers. --- source/snes9x/controls.cpp | 6 +++--- source/snes9x/gfx.cpp | 31 +++++++++++++++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/source/snes9x/controls.cpp b/source/snes9x/controls.cpp index 01ddcaa..328ae0c 100644 --- a/source/snes9x/controls.cpp +++ b/source/snes9x/controls.cpp @@ -2724,7 +2724,7 @@ static void do_polling (int mp) { case MAP_BUTTON: { - bool pressed; + bool pressed = false; if (S9xPollButton(*itr, &pressed)) S9xReportButton(*itr, pressed); break; @@ -2732,7 +2732,7 @@ static void do_polling (int mp) case MAP_AXIS: { - int16 value; + int16 value = 0; if (S9xPollAxis(*itr, &value)) S9xReportAxis(*itr, value); break; @@ -2740,7 +2740,7 @@ static void do_polling (int mp) case MAP_POINTER: { - int16 x, y; + int16 x = 0, y = 0; if (S9xPollPointer(*itr, &x, &y)) S9xReportPointer(*itr, x, y); break; diff --git a/source/snes9x/gfx.cpp b/source/snes9x/gfx.cpp index 1d1458d..bee4a3f 100644 --- a/source/snes9x/gfx.cpp +++ b/source/snes9x/gfx.cpp @@ -1902,10 +1902,11 @@ static void DisplayPressedKeys (void) { case CTL_MOUSE: { - uint8 buf[5], *p = buf; - MovieGetMouse(port, buf); - int16 x = READ_WORD(p); - int16 y = READ_WORD(p + 2); + uint8 buf[5]; + if (!MovieGetMouse(port, buf)) + break; + int16 x = READ_WORD(buf); + int16 y = READ_WORD(buf + 2); uint8 buttons = buf[4]; sprintf(string, "#%d %d: (%03d,%03d) %c%c", port, ids[0], x, y, (buttons & 0x40) ? 'L' : ' ', (buttons & 0x80) ? 'R' : ' '); @@ -1915,10 +1916,11 @@ static void DisplayPressedKeys (void) case CTL_SUPERSCOPE: { - uint8 buf[6], *p = buf; - MovieGetScope(port, buf); - int16 x = READ_WORD(p); - int16 y = READ_WORD(p + 2); + uint8 buf[6]; + if (!MovieGetScope(port, buf)) + break; + int16 x = READ_WORD(buf); + int16 y = READ_WORD(buf + 2); uint8 buttons = buf[4]; sprintf(string, "#%d %d: (%03d,%03d) %c%c%c%c", port, ids[0], x, y, (buttons & 0x80) ? 'F' : ' ', (buttons & 0x40) ? 'C' : ' ', @@ -1929,12 +1931,13 @@ static void DisplayPressedKeys (void) case CTL_JUSTIFIER: { - uint8 buf[11], *p = buf; - MovieGetJustifier(port, buf); - int16 x1 = READ_WORD(p); - int16 x2 = READ_WORD(p + 2); - int16 y1 = READ_WORD(p + 4); - int16 y2 = READ_WORD(p + 6); + uint8 buf[11]; + if (!MovieGetJustifier(port, buf)) + break; + int16 x1 = READ_WORD(buf); + int16 x2 = READ_WORD(buf + 2); + int16 y1 = READ_WORD(buf + 4); + int16 y2 = READ_WORD(buf + 6); uint8 buttons = buf[8]; bool8 offscreen1 = buf[9]; bool8 offscreen2 = buf[10];