[Scummvm-cvs-logs] SF.net SVN: scummvm:[53467] scummvm/trunk/engines/sword2
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Fri Oct 15 08:12:24 CEST 2010
Revision: 53467
http://scummvm.svn.sourceforge.net/scummvm/?rev=53467&view=rev
Author: eriktorbjorn
Date: 2010-10-15 06:12:23 +0000 (Fri, 15 Oct 2010)
Log Message:
-----------
SWORD2: Fix some code analysis warnings (bug #3087857)
Modified Paths:
--------------
scummvm/trunk/engines/sword2/controls.cpp
scummvm/trunk/engines/sword2/music.cpp
scummvm/trunk/engines/sword2/protocol.cpp
scummvm/trunk/engines/sword2/render.cpp
scummvm/trunk/engines/sword2/resman.cpp
Modified: scummvm/trunk/engines/sword2/controls.cpp
===================================================================
--- scummvm/trunk/engines/sword2/controls.cpp 2010-10-15 06:08:42 UTC (rev 53466)
+++ scummvm/trunk/engines/sword2/controls.cpp 2010-10-15 06:12:23 UTC (rev 53467)
@@ -180,12 +180,12 @@
byte *data = _vm->fetchTextLine(_vm->_resman->openResource(textId / SIZE), textId & 0xffff);
int i;
- for (i = 0; data[i + 2]; i++) {
- if (buf)
+ if (buf) {
+ for (i = 0; data[i + 2]; i++)
buf[i] = data[i + 2];
+ buf[i] = 0;
}
- buf[i] = 0;
_vm->_resman->closeResource(textId / SIZE);
}
Modified: scummvm/trunk/engines/sword2/music.cpp
===================================================================
--- scummvm/trunk/engines/sword2/music.cpp 2010-10-15 06:08:42 UTC (rev 53466)
+++ scummvm/trunk/engines/sword2/music.cpp 2010-10-15 06:12:23 UTC (rev 53467)
@@ -496,9 +496,16 @@
memset(buffer, 0, 2 * numSamples);
if (!_mixBuffer || numSamples > _mixBufferLen) {
- if (_mixBuffer)
- _mixBuffer = (int16 *)realloc(_mixBuffer, 2 * numSamples);
- else
+ if (_mixBuffer) {
+ int16 *newBuffer = (int16 *)realloc(_mixBuffer, 2 * numSamples);
+ if (newBuffer) {
+ _mixBuffer = newBuffer;
+ } else {
+ // We can't use the old buffer any more. It's too small.
+ free(_mixBuffer);
+ _mixBuffer = 0;
+ }
+ } else
_mixBuffer = (int16 *)malloc(2 * numSamples);
_mixBufferLen = numSamples;
Modified: scummvm/trunk/engines/sword2/protocol.cpp
===================================================================
--- scummvm/trunk/engines/sword2/protocol.cpp 2010-10-15 06:08:42 UTC (rev 53466)
+++ scummvm/trunk/engines/sword2/protocol.cpp 2010-10-15 06:12:23 UTC (rev 53467)
@@ -412,8 +412,8 @@
debug(2, "fetchPsxParallax() -> %s parallax, xRes: %u, yRes: %u", (level == 0) ? "Background" : "Foreground", plxXres, plxYres);
// Calculate the number of tiles which compose the parallax grid.
- horTiles = plxXres % 64 ? (plxXres / 64) + 1 : plxXres / 64;
- verTiles = plxYres % 16 ? (plxYres / 16) + 1 : plxYres / 16;
+ horTiles = (plxXres % 64) ? (plxXres / 64) + 1 : plxXres / 64;
+ verTiles = (plxYres % 16) ? (plxYres / 16) + 1 : plxYres / 16;
totSize = plxSize + horTiles * verTiles * 4 + 8;
Modified: scummvm/trunk/engines/sword2/render.cpp
===================================================================
--- scummvm/trunk/engines/sword2/render.cpp 2010-10-15 06:08:42 UTC (rev 53466)
+++ scummvm/trunk/engines/sword2/render.cpp 2010-10-15 06:12:23 UTC (rev 53467)
@@ -731,8 +731,8 @@
data = parallax + xTiles * yTiles * 4;
_xBlocks[_layer] = xTiles;
- _yBlocks[_layer] = (yTiles / 2) + (yTiles % 2 ? 1 : 0);
- bool oddTiles = (yTiles % 2 ? true : false);
+ _yBlocks[_layer] = (yTiles / 2) + ((yTiles % 2) ? 1 : 0);
+ bool oddTiles = ((yTiles % 2) ? true : false);
_blockSurfaces[_layer] = (BlockSurface **)calloc(_xBlocks[_layer] * _yBlocks[_layer], sizeof(BlockSurface *));
if (!_blockSurfaces[_layer])
Modified: scummvm/trunk/engines/sword2/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword2/resman.cpp 2010-10-15 06:08:42 UTC (rev 53466)
+++ scummvm/trunk/engines/sword2/resman.cpp 2010-10-15 06:12:23 UTC (rev 53467)
@@ -474,7 +474,7 @@
file->seek(table_offset);
assert((tableSize % 8) == 0);
- _resFiles[fileNum].entryTab = (uint32*)malloc(tableSize);
+ _resFiles[fileNum].entryTab = (uint32 *)malloc(tableSize);
_resFiles[fileNum].numEntries = tableSize / 8;
file->read(_resFiles[fileNum].entryTab, tableSize);
if (file->eos() || file->err())
@@ -482,7 +482,7 @@
#ifdef SCUMM_BIG_ENDIAN
for (int tabCnt = 0; tabCnt < _resFiles[fileNum].numEntries * 2; tabCnt++)
- _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]);
+ _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]);
#endif
}
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