[Scummvm-cvs-logs] SF.net SVN: scummvm:[52439] scummvm/branches/gsoc2010-plugins/backends/ plugins/elf-loader.cpp

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Sun Aug 29 13:14:14 CEST 2010


Revision: 52439
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52439&view=rev
Author:   dhewg
Date:     2010-08-29 11:14:14 +0000 (Sun, 29 Aug 2010)

Log Message:
-----------
PLUGINS: Fix warnings and unnecessary casts.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-08-29 11:10:18 UTC (rev 52438)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-08-29 11:14:14 UTC (rev 52439)
@@ -89,7 +89,6 @@
 }
 
 bool DLObject::readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr) {
-
 	// Start reading the elf header. Check for errors
 	if (DLFile->read(ehdr, sizeof(*ehdr)) != sizeof(*ehdr) ||
 	        memcmp(ehdr->e_ident, ELFMAG, SELFMAG) ||			// Check MAGIC
@@ -113,7 +112,6 @@
 }
 
 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 ||
 	    DLFile->read(phdr, sizeof(*phdr)) != sizeof(*phdr)) {
@@ -131,11 +129,9 @@
 	    phdr->p_offset, phdr->p_filesz, phdr->p_memsz, phdr->p_align);
 
 	return true;
-
 }
 
 bool DLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr) {
-
 	char *baseAddress = 0;
 
 	// Attempt to allocate memory for segment
@@ -163,7 +159,7 @@
 
 	// 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) {
+	        DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
 		seterror("Segment load failed.");
 		return false;
 	}
@@ -174,7 +170,6 @@
 }
 
 Elf32_Shdr * DLObject::loadSectionHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr) {
-
 	Elf32_Shdr *shdr = NULL;
 
 	// Allocate memory for section headers
@@ -186,7 +181,7 @@
 	// Read from file into section headers
 	if (DLFile->seek(ehdr->e_shoff, SEEK_SET) < 0 ||
 	        DLFile->read(shdr, ehdr->e_shnum * sizeof(*shdr)) !=
-	        (ssize_t)(ehdr->e_shnum * sizeof(*shdr))) {
+	        ehdr->e_shnum * sizeof(*shdr)) {
 		seterror("Section headers load failed.");
 		return NULL;
 	}
@@ -195,7 +190,6 @@
 }
 
 int DLObject::loadSymbolTable(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) {
-
 	// Loop over sections, looking for symbol table linked to a string table
 	for (int i = 0; i < ehdr->e_shnum; i++) {
 		if (shdr[i].sh_type == SHT_SYMTAB &&
@@ -224,7 +218,7 @@
 	// Read symbol table into memory
 	if (DLFile->seek(shdr[_symtab_sect].sh_offset, SEEK_SET) < 0 ||
 	        DLFile->read(_symtab, shdr[_symtab_sect].sh_size) !=
-	        (ssize_t)shdr[_symtab_sect].sh_size) {
+	        shdr[_symtab_sect].sh_size) {
 		seterror("Symbol table load failed.");
 		return -1;
 	}
@@ -234,11 +228,9 @@
 	DBG("Loaded %d symbols.\n", _symbol_cnt);
 
 	return _symtab_sect;
-
 }
 
 bool DLObject::loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *shdr) {
-
 	int string_sect = shdr[_symtab_sect].sh_link;
 
 	// Allocate memory for string table
@@ -250,7 +242,7 @@
 	// Read string table into memory
 	if (DLFile->seek(shdr[string_sect].sh_offset, SEEK_SET) < 0 ||
 	        DLFile->read(_strtab, shdr[string_sect].sh_size) !=
-	        (ssize_t)shdr[string_sect].sh_size) {
+	        shdr[string_sect].sh_size) {
 		seterror("Symbol table strings load failed.");
 		return false;
 	}
@@ -259,17 +251,11 @@
 }
 
 void DLObject::relocateSymbols(Elf32_Addr offset) {
-
-	int mainCount = 0;
-	int shortsCount= 0;
-
 	// Loop over symbols, add relocation offset
 	Elf32_Sym *s = (Elf32_Sym *)_symtab;
 	for (int c = _symbol_cnt; c--; s++) {
-
 		// Make sure we don't relocate special valued symbols
 		if (s->st_shndx < SHN_LOPROC) {
-				mainCount++;
 				s->st_value += offset;
 				if (s->st_value < (Elf32_Addr)_segment || s->st_value > (Elf32_Addr)_segment + _segmentSize)
 					seterror("Symbol out of bounds! st_value = %x\n", s->st_value);
@@ -288,7 +274,6 @@
 	}
 
 	for (int i = 0; i < ehdr.e_phnum; i++) {	//Load our segments
-
 		DBG("Loading segment %d\n", i);
 
 		if (readProgramHeaders(DLFile, &ehdr, &phdr, i) == false)
@@ -316,11 +301,9 @@
 	free(shdr);
 
 	return ret;
-
 }
 
 bool DLObject::open(const char *path) {
-
 	Common::SeekableReadStream* DLFile;
 	void *ctors_start, *ctors_end;
 
@@ -358,11 +341,11 @@
 		return false;
 	}
 
-	DBG(("Calling constructors.\n"));
+	DBG("Calling constructors.\n");
 	for (void (**f)(void) = (void (**)(void))ctors_start; f != ctors_end; f++)
 		(**f)();
 
-	DBG(("%s opened ok.\n", path));
+	DBG("%s opened ok.\n", path);
 
 	return true;
 }
@@ -377,7 +360,7 @@
 }
 
 void *DLObject::symbol(const char *name) {
-	DBG(("symbol(\"%s\")\n", name));
+	DBG("symbol(\"%s\")\n", name);
 
 	if (_symtab == NULL || _strtab == NULL || _symbol_cnt < 1) {
 		seterror("No symbol table loaded.");
@@ -386,7 +369,6 @@
 
 	Elf32_Sym *s = (Elf32_Sym *)_symtab;
 	for (int c = _symbol_cnt; c--; s++)
-
 		// We can only import symbols that are global or weak in the plugin
 		if ((SYM_BIND(s->st_info) == STB_GLOBAL || SYM_BIND(s->st_info) == STB_WEAK) &&
 		       !strcmp(name, _strtab + s->st_name)) {


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