aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins
diff options
context:
space:
mode:
authorAndre Heider2010-09-05 12:37:59 +0000
committerAndre Heider2010-09-05 12:37:59 +0000
commit253a0aa7f9756a16d4c6490cebba623b9352b945 (patch)
treef72be07557d966b9a4720319d206dc7bc5a71d57 /backends/plugins
parent07e3a422245e0fb118323ef95f354b81669231d3 (diff)
downloadscummvm-rg350-253a0aa7f9756a16d4c6490cebba623b9352b945.tar.gz
scummvm-rg350-253a0aa7f9756a16d4c6490cebba623b9352b945.tar.bz2
scummvm-rg350-253a0aa7f9756a16d4c6490cebba623b9352b945.zip
PLUGINS: Fix warnings.
svn-id: r52548
Diffstat (limited to 'backends/plugins')
-rw-r--r--backends/plugins/arm-loader.cpp4
-rw-r--r--backends/plugins/elf-loader.cpp39
-rw-r--r--backends/plugins/elf-provider.cpp18
-rw-r--r--backends/plugins/mips-loader.cpp14
-rw-r--r--backends/plugins/shorts-segment-manager.cpp2
5 files changed, 36 insertions, 41 deletions
diff --git a/backends/plugins/arm-loader.cpp b/backends/plugins/arm-loader.cpp
index 7fd4c12e65..e2aa8e9fe1 100644
--- a/backends/plugins/arm-loader.cpp
+++ b/backends/plugins/arm-loader.cpp
@@ -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 @@ bool ARMDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long off
// 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;
diff --git a/backends/plugins/elf-loader.cpp b/backends/plugins/elf-loader.cpp
index ac65bcb8e8..1f6dcd7d7a 100644
--- a/backends/plugins/elf-loader.cpp
+++ b/backends/plugins/elf-loader.cpp
@@ -67,8 +67,8 @@ static void flushDataCache(void *ptr, uint32 len) {
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::discard_symtab() {
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::readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehd
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 @@ bool DLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr)
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 @@ bool DLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr)
}
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 @@ int DLObject::loadSymbolTable(Common::SeekableReadStream* DLFile, Elf32_Ehdr *eh
}
// 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 @@ bool DLObject::loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *s
}
// 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 @@ bool DLObject::load(Common::SeekableReadStream* DLFile) {
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 @@ bool DLObject::open(const char *path) {
_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::open(const char *path) {
}
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 @@ bool DLObject::close() {
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 @@ void *DLObject::symbol(const char *name) {
// 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) */
diff --git a/backends/plugins/elf-provider.cpp b/backends/plugins/elf-provider.cpp
index 47f0436ab9..00d93fcd34 100644
--- a/backends/plugins/elf-provider.cpp
+++ b/backends/plugins/elf-provider.cpp
@@ -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 @@ bool ELFPlugin::loadPlugin() {
_dlHandle = obj;
} else {
delete obj;
- _dlHandle = NULL;
+ _dlHandle = 0;
}
if (!_dlHandle) {
diff --git a/backends/plugins/mips-loader.cpp b/backends/plugins/mips-loader.cpp
index 67e12949d8..5a0db74041 100644
--- a/backends/plugins/mips-loader.cpp
+++ b/backends/plugins/mips-loader.cpp
@@ -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 @@ bool MIPSDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long of
}
// 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 @@ bool MIPSDLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *p
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 @@ bool MIPSDLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *p
void MIPSDLObject::unload() {
discard_symtab();
free(_segment);
- _segment = NULL;
+ _segment = 0;
if (_shortsSegment) {
ShortsMan.deleteSegment(_shortsSegment);
- _shortsSegment = NULL;
+ _shortsSegment = 0;
}
}
diff --git a/backends/plugins/shorts-segment-manager.cpp b/backends/plugins/shorts-segment-manager.cpp
index 788d7807ce..dfb3f9093a 100644
--- a/backends/plugins/shorts-segment-manager.cpp
+++ b/backends/plugins/shorts-segment-manager.cpp
@@ -59,7 +59,7 @@ ShortSegmentManager::Segment *ShortSegmentManager::newSegment(int size, char *or
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