[Scummvm-cvs-logs] SF.net SVN: scummvm:[52548] scummvm/branches/gsoc2010-plugins/backends/ plugins

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Sun Sep 5 14:37:59 CEST 2010


Revision: 52548
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52548&view=rev
Author:   dhewg
Date:     2010-09-05 12:37:59 +0000 (Sun, 05 Sep 2010)

Log Message:
-----------
PLUGINS: Fix warnings.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp	2010-09-05 12:37:36 UTC (rev 52547)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp	2010-09-05 12:37:59 UTC (rev 52548)
@@ -39,7 +39,7 @@
  *
  */
 bool ARMDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
-	Elf32_Rel *rel = NULL; //relocation entry
+	Elf32_Rel *rel = 0; //relocation entry
 
 	// Allocate memory for relocation table
 	if (!(rel = (Elf32_Rel *)malloc(size))) {
@@ -49,7 +49,7 @@
 
 	// Read in our relocation table
 	if (DLFile->seek(offset, SEEK_SET) < 0 ||
-	        DLFile->read(rel, size) != (ssize_t)size) {
+	        DLFile->read(rel, size) != size) {
 		warning("elfloader: Relocation table load failed.");
 		free(rel);
 		return false;

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-09-05 12:37:36 UTC (rev 52547)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-09-05 12:37:59 UTC (rev 52548)
@@ -67,8 +67,8 @@
 void DLObject::discard_symtab() {
 	free(_symtab);
 	free(_strtab);
-	_symtab = NULL;
-	_strtab = NULL;
+	_symtab = 0;
+	_strtab = 0;
 	_symbol_cnt = 0;
 }
 
@@ -76,7 +76,7 @@
 void DLObject::unload() {
 	discard_symtab();
 	free(_segment);
-	_segment = NULL;
+	_segment = 0;
 }
 
 bool DLObject::readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr) {
@@ -104,7 +104,7 @@
 
 bool DLObject::readProgramHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, int num) {
 	// Read program header
-	if (DLFile->seek(ehdr->e_phoff + sizeof(*phdr)*num, SEEK_SET) < 0 ||
+	if (!DLFile->seek(ehdr->e_phoff + sizeof(*phdr)*num, SEEK_SET) ||
 	    DLFile->read(phdr, sizeof(*phdr)) != sizeof(*phdr)) {
 		warning("elfloader: Program header load failed.");
 		return false;
@@ -149,7 +149,7 @@
 	debug(2, "elfloader: Reading the segment into memory");
 
 	// Read the segment into memory
-	if (DLFile->seek(phdr->p_offset, SEEK_SET) < 0 ||
+	if (!DLFile->seek(phdr->p_offset, SEEK_SET) ||
 	        DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
 		warning("elfloader: Segment load failed.");
 		return false;
@@ -161,20 +161,20 @@
 }
 
 Elf32_Shdr * DLObject::loadSectionHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr) {
-	Elf32_Shdr *shdr = NULL;
+	Elf32_Shdr *shdr = 0;
 
 	// Allocate memory for section headers
 	if (!(shdr = (Elf32_Shdr *)malloc(ehdr->e_shnum * sizeof(*shdr)))) {
 		warning("elfloader: Out of memory.");
-		return NULL;
+		return 0;
 	}
 
 	// Read from file into section headers
-	if (DLFile->seek(ehdr->e_shoff, SEEK_SET) < 0 ||
+	if (!DLFile->seek(ehdr->e_shoff, SEEK_SET) ||
 	        DLFile->read(shdr, ehdr->e_shnum * sizeof(*shdr)) !=
 	        ehdr->e_shnum * sizeof(*shdr)) {
 		warning("elfloader: Section headers load failed.");
-		return NULL;
+		return 0;
 	}
 
 	return shdr;
@@ -207,7 +207,7 @@
 	}
 
 	// Read symbol table into memory
-	if (DLFile->seek(shdr[_symtab_sect].sh_offset, SEEK_SET) < 0 ||
+	if (!DLFile->seek(shdr[_symtab_sect].sh_offset, SEEK_SET) ||
 	        DLFile->read(_symtab, shdr[_symtab_sect].sh_size) !=
 	        shdr[_symtab_sect].sh_size) {
 		warning("elfloader: Symbol table load failed.");
@@ -231,7 +231,7 @@
 	}
 
 	// Read string table into memory
-	if (DLFile->seek(shdr[string_sect].sh_offset, SEEK_SET) < 0 ||
+	if (!DLFile->seek(shdr[string_sect].sh_offset, SEEK_SET) ||
 	        DLFile->read(_strtab, shdr[string_sect].sh_size) !=
 	        shdr[string_sect].sh_size) {
 		warning("elfloader: Symbol table strings load failed.");
@@ -274,7 +274,7 @@
 			return false;
 	}
 
-	if ((shdr = loadSectionHeaders(DLFile, &ehdr)) == NULL)
+	if ((shdr = loadSectionHeaders(DLFile, &ehdr)) == 0)
 		ret = false;
 
 	if (ret && ((_symtab_sect = loadSymbolTable(DLFile, &ehdr, shdr)) < 0))
@@ -324,10 +324,9 @@
 	_dtors_start = symbol("___plugin_dtors");
 	_dtors_end = symbol("___plugin_dtors_end");
 
-	if (ctors_start == NULL || ctors_end == NULL || _dtors_start == NULL ||
-	        _dtors_end == NULL) {
+	if (!ctors_start || !ctors_end || !_dtors_start || !_dtors_end) {
 		warning("elfloader: Missing ctors/dtors.");
-		_dtors_start = _dtors_end = NULL;
+		_dtors_start = _dtors_end = 0;
 		unload();
 		return false;
 	}
@@ -342,10 +341,10 @@
 }
 
 bool DLObject::close() {
-	if (_dtors_start != NULL && _dtors_end != NULL)
+	if (_dtors_start && _dtors_end)
 		for (void (**f)(void) = (void (**)(void))_dtors_start; f != _dtors_end; f++)
 			(**f)();
-	_dtors_start = _dtors_end = NULL;
+	_dtors_start = _dtors_end = 0;
 	unload();
 	return true;
 }
@@ -353,9 +352,9 @@
 void *DLObject::symbol(const char *name) {
 	debug(2, "elfloader: Symbol(\"%s\")", name);
 
-	if (_symtab == NULL || _strtab == NULL || _symbol_cnt < 1) {
+	if (!_symtab || !_strtab || _symbol_cnt < 1) {
 		warning("elfloader: No symbol table loaded.");
-		return NULL;
+		return 0;
 	}
 
 	Elf32_Sym *s = (Elf32_Sym *)_symtab;
@@ -371,7 +370,7 @@
 
 	// We didn't find the symbol
 	warning("elfloader: Symbol \"%s\" not found.", name);
-	return NULL;
+	return 0;
 }
 
 #endif /* defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET) */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp	2010-09-05 12:37:36 UTC (rev 52547)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp	2010-09-05 12:37:59 UTC (rev 52548)
@@ -31,20 +31,16 @@
 #include "common/fs.h"
 
 DynamicPlugin::VoidFunc ELFPlugin::findSymbol(const char *symbol) {
-	void *func;
-	bool handleNull;
-	if (_dlHandle == NULL) {
-		func = NULL;
-		handleNull = true;
-	} else {
+	void *func = 0;
+
+	if (_dlHandle)
 		func = _dlHandle->symbol(symbol);
-	}
+
 	if (!func) {
-		if (handleNull) {
+		if (!_dlHandle)
 			warning("elfloader: Failed loading symbol '%s' from plugin '%s' (Handle is NULL)", symbol, _filename.c_str());
-		} else {
+		else
 			warning("elfloader: Failed loading symbol '%s' from plugin '%s'", symbol, _filename.c_str());
-		}
 	}
 
 	// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
@@ -64,7 +60,7 @@
 			_dlHandle = obj;
 		} else {
 			delete obj;
-			_dlHandle = NULL;
+			_dlHandle = 0;
 		}
 
 		if (!_dlHandle) {

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp	2010-09-05 12:37:36 UTC (rev 52547)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp	2010-09-05 12:37:59 UTC (rev 52548)
@@ -39,7 +39,7 @@
  *
  */
 bool MIPSDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
-	Elf32_Rel *rel = NULL;	// relocation entry
+	Elf32_Rel *rel = 0;	// relocation entry
 
 	// Allocate memory for relocation table
 	if (!(rel = (Elf32_Rel *)malloc(size))) {
@@ -48,8 +48,8 @@
 	}
 
 	// Read in our relocation table
-	if (DLFile->seek(offset, SEEK_SET) < 0 ||
-	        DLFile->read(rel, size) != (ssize_t)size) {
+	if (!DLFile->seek(offset, SEEK_SET) ||
+	        DLFile->read(rel, size) != size) {
 		warning("elfloader: Relocation table load failed.");
 		free(rel);
 		return false;
@@ -317,8 +317,8 @@
 	debug(2, "elfloader: Reading the segment into memory");
 
 	// Read the segment into memory
-	if (DLFile->seek(phdr->p_offset, SEEK_SET) < 0 ||
-	        DLFile->read(baseAddress, phdr->p_filesz) != (ssize_t)phdr->p_filesz) {
+	if (!DLFile->seek(phdr->p_offset, SEEK_SET) ||
+	        DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
 		warning("elfloader: Segment load failed.");
 		return false;
 	}
@@ -332,11 +332,11 @@
 void MIPSDLObject::unload() {
 	discard_symtab();
 	free(_segment);
-	_segment = NULL;
+	_segment = 0;
 
 	if (_shortsSegment) {
 		ShortsMan.deleteSegment(_shortsSegment);
-		_shortsSegment = NULL;
+		_shortsSegment = 0;
 	}
 }
 

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp	2010-09-05 12:37:36 UTC (rev 52547)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp	2010-09-05 12:37:59 UTC (rev 52548)
@@ -59,7 +59,7 @@
 	if (lastAddress + size > _shortsEnd) {
 		warning("elfloader: No space in shorts segment for %x bytes. Last address is %p, max address is %p.",
 		         size, lastAddress, _shortsEnd);
-		return NULL;
+		return 0;
 	}
 
 	Segment *seg = new Segment(lastAddress, size, origAddr);	// Create a new segment


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