[Scummvm-cvs-logs] SF.net SVN: scummvm:[53567] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Oct 18 18:00:08 CEST 2010


Revision: 53567
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53567&view=rev
Author:   fingolfin
Date:     2010-10-18 16:00:07 +0000 (Mon, 18 Oct 2010)

Log Message:
-----------
SCUMM: Fix parts of bug #3087898 (SCUMM: Code analysis warnings)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/debugger.cpp
    scummvm/trunk/engines/scumm/he/resource_he.cpp
    scummvm/trunk/engines/scumm/insane/insane.cpp
    scummvm/trunk/engines/scumm/object.cpp
    scummvm/trunk/engines/scumm/palette.cpp
    scummvm/trunk/engines/scumm/script_v5.cpp
    scummvm/trunk/engines/scumm/scumm.cpp

Modified: scummvm/trunk/engines/scumm/debugger.cpp
===================================================================
--- scummvm/trunk/engines/scumm/debugger.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/debugger.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -87,7 +87,7 @@
 	if (_vm->_game.id == GID_LOOM)
 		DCmd_Register("drafts",  WRAP_METHOD(ScummDebugger, Cmd_PrintDraft));
 
-	if (_vm->_game.id == GID_MONKEY && Common::kPlatformSegaCD)
+	if (_vm->_game.id == GID_MONKEY && _vm->_game.platform == Common::kPlatformSegaCD)
 		DCmd_Register("passcode",  WRAP_METHOD(ScummDebugger, Cmd_Passcode));
 
 	DCmd_Register("loadgame",  WRAP_METHOD(ScummDebugger, Cmd_LoadGame));

Modified: scummvm/trunk/engines/scumm/he/resource_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/he/resource_he.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -281,11 +281,13 @@
 	if ((id = strtol(type_wr->id, 0, 10)) != 0)
 		type = res_type_id_to_string(id);
 
-	debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s%s%s [size=%d]",
-	  name_wr->get_resource_id_quoted(),
-	  (lang_wr->id[0] != '\0' ? " language: " : ""),
-	  lang_wr->get_resource_id_quoted(), size);
-
+	if (lang_wr != NULL && lang_wr->id[0] != '\0') {
+		debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s language: %s [size=%d]",
+		  name_wr->get_resource_id_quoted(), lang_wr->get_resource_id_quoted(), size);
+	} else {
+		debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s [size=%d]",
+		  name_wr->get_resource_id_quoted(), size);
+	}
 	return size;
 }
 
@@ -696,6 +698,7 @@
 			return false;
 		}
 		fi->memory = (byte *)realloc(fi->memory, fi->total_size);
+		assert(fi->memory);
 
 		/* relocate memory, start from last section */
 		pe_header = PE_HEADER(fi->memory);

Modified: scummvm/trunk/engines/scumm/insane/insane.cpp
===================================================================
--- scummvm/trunk/engines/scumm/insane/insane.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/insane/insane.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -944,7 +944,7 @@
 	bool retvalue = 0;
 	unsigned int i;
 
-	for (i = 0; i < sizeof(spans); i++) {
+	for (i = 0; i < ARRAYSIZE(spans); i++) {
 		retvalue = !retvalue;
 		if (spans[i] <= state)
 			break;
@@ -1099,7 +1099,7 @@
 	bool retvalue = 1;
 	unsigned int i;
 
-	for (i = 0; i < sizeof(spans); i++) {
+	for (i = 0; i < ARRAYSIZE(spans); i++) {
 		retvalue = !retvalue;
 		if (spans[i] >= state)
 			break;
@@ -1119,7 +1119,7 @@
 	bool retvalue = 1;
 	unsigned int i;
 
-	for (i = 0; i < sizeof(spans); i++) {
+	for (i = 0; i < ARRAYSIZE(spans); i++) {
 		retvalue = !retvalue;
 		if (spans[i] >= state)
 			break;

Modified: scummvm/trunk/engines/scumm/object.cpp
===================================================================
--- scummvm/trunk/engines/scumm/object.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/object.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -993,6 +993,7 @@
 	od->flags = Gdi::dbAllowMaskOr;
 
 	if (_game.version == 8) {
+		assert(imhd);
 		od->obj_nr = READ_LE_UINT16(&(cdhd->v7.obj_id));
 
 		od->parent = cdhd->v7.parent;
@@ -1008,6 +1009,7 @@
 			od->flags = ((((byte)READ_LE_UINT32(&imhd->v8.flags)) & 16) == 0) ? Gdi::dbAllowMaskOr : 0;
 
 	} else if (_game.version == 7) {
+		assert(imhd);
 		od->obj_nr = READ_LE_UINT16(&(cdhd->v7.obj_id));
 
 		od->parent = cdhd->v7.parent;
@@ -1020,6 +1022,7 @@
 		od->actordir = (byte)READ_LE_UINT16(&imhd->v7.actordir);
 
 	} else if (_game.version == 6) {
+		assert(imhd);
 		od->obj_nr = READ_LE_UINT16(&(cdhd->v6.obj_id));
 
 		od->width = READ_LE_UINT16(&cdhd->v6.w);

Modified: scummvm/trunk/engines/scumm/palette.cpp
===================================================================
--- scummvm/trunk/engines/scumm/palette.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/palette.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -498,7 +498,7 @@
 	int i, j;
 
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
-	if (_game.platform == Common::kPlatformFMTowns && (!_townsPaletteFlags & 1))
+	if (_game.platform == Common::kPlatformFMTowns && !(_townsPaletteFlags & 1))
 		return;
 #endif
 
@@ -544,7 +544,7 @@
 
 void ScummEngine::palManipulateInit(int resID, int start, int end, int time) {
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
-	if (_game.platform == Common::kPlatformFMTowns && (!_townsPaletteFlags & 1))
+	if (_game.platform == Common::kPlatformFMTowns && !(_townsPaletteFlags & 1))
 		return;
 #endif
 

Modified: scummvm/trunk/engines/scumm/script_v5.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v5.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/script_v5.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -1849,6 +1849,7 @@
 						break;
 					len *= 2;
 					ptr = (byte *)realloc(ptr, len);
+					assert(ptr);
 				}
 				ptr[cnt] = '\0';
 				loadPtrToResource(rtString, a, ptr);

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2010-10-18 11:09:36 UTC (rev 53566)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2010-10-18 16:00:07 UTC (rev 53567)
@@ -136,7 +136,8 @@
 		uint tmpVal;
 		tmpStr[0] = dr.md5[2*i];
 		tmpStr[1] = dr.md5[2*i+1];
-		sscanf(tmpStr, "%x", &tmpVal);
+		int res = sscanf(tmpStr, "%x", &tmpVal);
+		assert(res == 1);
 		_gameMD5[i] = (byte)tmpVal;
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list