- coverity based bug fixes - round #1

This commit is contained in:
SoftCoder
2013-12-13 23:04:12 -08:00
parent c887b0c357
commit b9d6b38e8f
53 changed files with 651 additions and 416 deletions

View File

@@ -426,15 +426,16 @@ int Properties::getInt(const string &key, int min, int max,const char *defaultVa
}
float Properties::getFloat(const string &key, const char *defaultValueIfNotFound) const{
float result = 0.0;
try{
return strToFloat(getString(key,defaultValueIfNotFound));
result = strToFloat(getString(key,defaultValueIfNotFound));
}
catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
//throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]");
}
return 0.0;
return result;
}
float Properties::getFloat(const string &key, float min, float max, const char *defaultValueIfNotFound) const{
@@ -543,15 +544,16 @@ int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const
}
float Properties::getFloat(const char *key, const char *defaultValueIfNotFound) const{
float result = 0.0;
try{
return strToFloat(getString(key,defaultValueIfNotFound));
result = strToFloat(getString(key,defaultValueIfNotFound));
}
catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
//throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]");
}
return 0.0;
return result;
}
const string Properties::getString(const char *key, const char *defaultValueIfNotFound) const{

View File

@@ -378,7 +378,10 @@ void SystemFlags::Close() {
SystemFlags::lockFileCountIndex = -1;
if(SystemFlags::lockfilename != "") {
remove(SystemFlags::lockfilename.c_str());
bool remove_result = remove(SystemFlags::lockfilename.c_str());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] remove_result = %d for file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,remove_result,SystemFlags::lockfilename.c_str());
SystemFlags::lockfilename = "";
}
}
@@ -468,18 +471,20 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
// If the file is already open (shared) by another debug type
// do not over-write the file but share the stream pointer
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
SystemFlags::SystemFlagsType &currentDebugLog2 = iterMap->second;
if(SystemFlags::debugLogFileList != NULL) {
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
SystemFlags::SystemFlagsType &currentDebugLog2 = iterMap->second;
if( iterMap->first != type &&
currentDebugLog.debugLogFileName == currentDebugLog2.debugLogFileName &&
currentDebugLog2.fileStream != NULL) {
currentDebugLog.fileStream = currentDebugLog2.fileStream;
currentDebugLog.fileStreamOwner = false;
currentDebugLog.mutex = currentDebugLog2.mutex;
break;
}
if( iterMap->first != type &&
currentDebugLog.debugLogFileName == currentDebugLog2.debugLogFileName &&
currentDebugLog2.fileStream != NULL) {
currentDebugLog.fileStream = currentDebugLog2.fileStream;
currentDebugLog.fileStreamOwner = false;
currentDebugLog.mutex = currentDebugLog2.mutex;
break;
}
}
}
string debugLog = currentDebugLog.debugLogFileName;