From ce0cc0ee857740cb0bd1ebd3b4bfa6eefc31aee6 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 17 Apr 2011 14:48:27 +0300 Subject: COMMON: Partial fix for #3087922: COMMON/BASE/BACKENDS: Code analysis warnings --- backends/platform/sdl/sdl.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'backends/platform/sdl/sdl.cpp') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index d6e79248f9..2c0c45907f 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -378,7 +378,11 @@ void OSystem_SDL::setupIcon() { unsigned int rgba[256]; unsigned int *icon; - sscanf(scummvm_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes); + if (sscanf(scummvm_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) { + warning("Wrong format of scummvm_icon[0] (%s)", scummvm_icon[0]); + + return; + } if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) { warning("Could not load the built-in icon (%d %d %d %d)", w, h, ncols, nbytes); return; @@ -393,13 +397,17 @@ void OSystem_SDL::setupIcon() { unsigned char code; char color[32]; unsigned int col; - sscanf(scummvm_icon[1 + i], "%c c %s", &code, color); + if (sscanf(scummvm_icon[1 + i], "%c c %s", &code, color) != 2) { + warning("Wrong format of scummvm_icon[%d] (%s)", 1 + i, scummvm_icon[1 + i]); + } if (!strcmp(color, "None")) col = 0x00000000; else if (!strcmp(color, "black")) col = 0xFF000000; else if (color[0] == '#') { - sscanf(color + 1, "%06x", &col); + if (sscanf(color + 1, "%06x", &col) != 1) { + warning("Wrong format of color (%s)", color + 1); + } col |= 0xFF000000; } else { warning("Could not load the built-in icon (%d %s - %s) ", code, color, scummvm_icon[1 + i]); -- cgit v1.2.3 From 9414d7a6e287ff8abfb5746b564e92c8f0e6de58 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sun, 24 Apr 2011 11:34:27 +0300 Subject: JANITORIAL: Reduce header dependencies in shared code Some backends may break as I only compiled SDL --- backends/platform/sdl/sdl.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/platform/sdl/sdl.cpp') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 2c0c45907f..4694a061a3 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -32,6 +32,7 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/EventRecorder.h" +#include "common/textconsole.h" #include "backends/saves/default/default-saves.h" #include "backends/audiocd/sdl/sdl-audiocd.h" -- cgit v1.2.3 From 59e77ed66779d33a14a5f4d2a5885a70b793f36f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 2 May 2011 14:42:08 +0200 Subject: ALL: Mark printf and various other symbols as forbidden Right now, a few places in the frontend code still use printf and consorts. We mark the affected files with a FIXME for now, and add a dedicated exception for each. To be fixed! Also tweak FORBIDDEN_SYMBOL_REPLACEMENT to hopefully really always enforce a compiler error --- backends/platform/sdl/sdl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'backends/platform/sdl/sdl.cpp') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 4694a061a3..bc27f8e954 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -23,6 +23,9 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h + + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include -- cgit v1.2.3 From 3d4e9fe674d2daf59ff4b481fc2f89f77b390a4f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 3 May 2011 11:27:44 +0200 Subject: BACKENDS: Allow various files to use stuff from time.h --- backends/platform/sdl/sdl.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'backends/platform/sdl/sdl.cpp') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index bc27f8e954..e6ca423f61 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -25,7 +25,6 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_time_h - #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include -- cgit v1.2.3