From 7b6271b48d4fb6ebfe61ee8a80c8329a19c119c0 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 27 Oct 2014 18:59:37 -0700 Subject: [PATCH] fix more warnings --- .../application/Miff/src/win32/miff.cpp | 44 ++++++++----------- .../src/shared/CentralServer.cpp | 4 +- .../ChatServer/src/shared/ChatInterface.cpp | 6 +-- .../ChatServer/src/shared/ChatServer.cpp | 19 +++----- .../src/shared/ClientConnection.cpp | 2 +- .../src/shared/ConnectionServer.cpp | 8 +--- .../LoginServer/src/shared/LoginServer.cpp | 21 ++++----- .../PlanetServer/src/shared/PlanetServer.cpp | 3 -- .../src/shared/object/CreatureObject.cpp | 19 +++----- .../serverScript/src/shared/JavaLibrary.cpp | 1 + .../src/shared/RemoteDebug_inner.cpp | 2 +- .../sharedFile/src/shared/FileStreamer.cpp | 2 +- .../src/shared/FileStreamerThread.h | 2 +- .../library/sharedFile/src/shared/Iff.cpp | 1 - .../src/shared/tree/XmlTreeDocument.cpp | 2 - .../platform/projects/MonAPI2/MonitorAPI.cpp | 23 +++------- .../platform/projects/MonAPI2/MonitorData.cpp | 7 +-- .../library/platform/utils/Base/Config.cpp | 6 --- .../library/platform/utils/Base/ScopeLock.h | 1 - .../CSAssist/CSAssistgameapi/response.cpp | 25 ----------- .../CSAssist/utils/Base/Config.cpp | 6 --- .../CSAssist/utils/TcpLibrary/TcpManager.h | 4 +- .../CSAssist/utils/Unicode/utf8.cpp | 11 +++-- .../soePlatform/ChatAPI/utils/Base/Config.cpp | 7 --- .../ChatAPI/utils/Unicode/utf8.cpp | 10 ++--- .../utils2.0/utils/Base/monitorAPI.cpp | 5 +-- 26 files changed, 71 insertions(+), 170 deletions(-) diff --git a/engine/client/application/Miff/src/win32/miff.cpp b/engine/client/application/Miff/src/win32/miff.cpp index a935b72d..43fca051 100644 --- a/engine/client/application/Miff/src/win32/miff.cpp +++ b/engine/client/application/Miff/src/win32/miff.cpp @@ -605,27 +605,21 @@ static errorType loadInputToBuffer( { errorType retVal = ERR_NONE; InputFileHandler *inFileHandler = new InputFileHandler("mIFF.$$$"); - if (inFileHandler) - { - int sizeRead = inFileHandler->read(dest, maxBufferSize); - if (sizeRead >= maxBufferSize) - { - retVal = ERR_BUFFERTOOSMALL; - } - else - { - reinterpret_cast(dest)[sizeRead] = 0; // so stupid... but if you don't zero-terminate at exact spot, YYInput may chokes because of extra grammer that may exist... - } - if (!debugMode) - inFileHandler->deleteFile("mIFF.$$$", true); // no need for temp file now... - // we've successfully read the file, now close it... - delete inFileHandler; - } - else // inFileName is NULL + int sizeRead = inFileHandler->read(dest, maxBufferSize); + if (sizeRead >= maxBufferSize) { - retVal = ERR_FILENOTFOUND; + retVal = ERR_BUFFERTOOSMALL; } + else + { + reinterpret_cast(dest)[sizeRead] = 0; // so stupid... but if you don't zero-terminate at exact spot, YYInput may chokes because of extra grammer that may exist... + } + if (!debugMode) + inFileHandler->deleteFile("mIFF.$$$", true); // no need for temp file now... + + // we've successfully read the file, now close it... + delete inFileHandler; return(retVal); } @@ -909,16 +903,14 @@ extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSiz return(sizeRead); // should be -1 InputFileHandler * inFileName = new InputFileHandler(fname); - if (inFileName) + + sizeRead = inFileName->read(buffer, maxBufferSize); + if (static_cast(sizeRead) >= maxBufferSize) { - sizeRead = inFileName->read(buffer, maxBufferSize); - if (static_cast(sizeRead) >= maxBufferSize) - { - handleError(ERR_BUFFERTOOSMALL); - sizeRead = -1; - } - delete inFileName; + handleError(ERR_BUFFERTOOSMALL); + sizeRead = -1; } + delete inFileName; return(sizeRead); } diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.cpp b/engine/server/application/CentralServer/src/shared/CentralServer.cpp index 35d9e51c..f7110e13 100644 --- a/engine/server/application/CentralServer/src/shared/CentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/CentralServer.cpp @@ -1177,7 +1177,6 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons else if(message.isType("DatabaseConsoleReplyMessage")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage > msg(ri); IGNORE_RETURN(sendToRandomGameServer(msg)); @@ -2657,7 +2656,6 @@ void CentralServer::run(void) setup.port = ConfigCentralServer::getConnectionServicePort(); setup.bindInterface = ConfigCentralServer::getConnectionServiceBindInterface(); Service * cons = new Service(ConnectionAllocator(), setup); - NOT_NULL(cons); cserver.m_connService = cons; setup.port = ConfigCentralServer::getConsoleServicePort(); @@ -2743,7 +2741,7 @@ void CentralServer::run(void) Os::sleep(1); } - } while (!barrierReached && !cserver.m_done); + } while (!cserver.m_done); //@todo Central needs to run a clock so we can schedule re-tries with the login server. { diff --git a/engine/server/application/ChatServer/src/shared/ChatInterface.cpp b/engine/server/application/ChatServer/src/shared/ChatInterface.cpp index 326639d0..1ad72571 100644 --- a/engine/server/application/ChatServer/src/shared/ChatInterface.cpp +++ b/engine/server/application/ChatServer/src/shared/ChatInterface.cpp @@ -2881,7 +2881,7 @@ void ChatInterface::OnReceivePersistentMessage(const ChatAvatar *destAvatar, con DEBUG_WARNING(true, ("We received an OnREceivePersistentMessage with a success result code but NULL data. This is an error that the API should never give.")); return; } - if (!destAvatar || !header) + if (!header) { return; } @@ -3020,10 +3020,6 @@ void ChatInterface::OnReceiveInstantMessage(const ChatAvatar *srcAvatar, const C DEBUG_WARNING(true, ("We received an OnReceiveInstantMessage with a success result code but NULL data. This is an error that the API should never give.")); return; } - if (!srcAvatar || !destAvatar) - { - return; - } ChatAvatarId fromId; makeAvatarId(*srcAvatar, fromId); ChatAvatarId toId; diff --git a/engine/server/application/ChatServer/src/shared/ChatServer.cpp b/engine/server/application/ChatServer/src/shared/ChatServer.cpp index 12bd3d2d..66241280 100644 --- a/engine/server/application/ChatServer/src/shared/ChatServer.cpp +++ b/engine/server/application/ChatServer/src/shared/ChatServer.cpp @@ -477,24 +477,17 @@ void ChatServer::onEnumerateServers(const EnumerateServers & e) ConnectionServerConnection * c = new ConnectionServerConnection(e.getAddress(), e.getPort()); - if (c != NULL) + if ( !e.getAddress().empty() + && (e.getPort() != 0)) { - if ( !e.getAddress().empty() - && (e.getPort() != 0)) - { - ChatServer::fileLog(true, "ChatServer", "onEnumerateServers() count(%d) address(%s)", count, getConnectionAddress(c).c_str()); + ChatServer::fileLog(true, "ChatServer", "onEnumerateServers() count(%d) address(%s)", count, getConnectionAddress(c).c_str()); - IGNORE_RETURN(connectionServerConnections.insert(c)); - s_chatServerMetricsData->setConnectionServerConnectionCount(instance().connectionServerConnections.size()); - } - else - { - ChatServer::fileLog(true, "ChatServer", "onEnumerateServers() count(%d) Empty server address", count); - } + IGNORE_RETURN(connectionServerConnections.insert(c)); + s_chatServerMetricsData->setConnectionServerConnectionCount(instance().connectionServerConnections.size()); } else { - ChatServer::fileLog(true, "ChatServer", "onEnumerateServers() count(%d) NULL connection", count); + ChatServer::fileLog(true, "ChatServer", "onEnumerateServers() count(%d) Empty server address", count); } }//lint !e429 Custodial pointer 'c' (line 232) has not been freed or returned //jrandall tracked by connectionServerConnections break; diff --git a/engine/server/application/ConnectionServer/src/shared/ClientConnection.cpp b/engine/server/application/ConnectionServer/src/shared/ClientConnection.cpp index f7b3020b..50f2ee0f 100644 --- a/engine/server/application/ConnectionServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ClientConnection.cpp @@ -1006,7 +1006,7 @@ void ClientConnection::onReceive(const Archive::ByteStream & message) else { //Forward on to Game Server - DEBUG_REPORT_LOG((!m_client || !m_client->getGameConnection()), ("Warn, received game message with no game connection. This may happen for a short time after a GameServer crashes. If it continues to happen, it indicates a bug.\n")); + DEBUG_REPORT_LOG(!m_client || !m_client->getGameConnection()), ("Warn, received game message with no game connection. This may happen for a short time after a GameServer crashes. If it continues to happen, it indicates a bug.\n"); if (m_client && m_client->getGameConnection()) { diff --git a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp index b54d6340..14652117 100644 --- a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp @@ -198,7 +198,6 @@ bool ConnectionServer::decryptToken(const KeyShare::Token & token, uint32 & stat uint32 len = sizeof(uint32) + sizeof(bool) + MAX_ACCOUNT_NAME_LENGTH + 1; unsigned char * keyBuffer = new unsigned char[len]; unsigned char * keyBufferPointer = keyBuffer; - NOT_NULL(keyBuffer); memset(keyBuffer, 0, len); @@ -228,7 +227,6 @@ bool ConnectionServer::decryptToken(const KeyShare::Token & token, char* session uint32 len = apiSessionIdWidth + sizeof(StationId); unsigned char * keyBuffer = new unsigned char[len + 1]; unsigned char * keyBufferPointer = keyBuffer; - NOT_NULL(keyBuffer); memset(keyBuffer, 0, sizeof(*keyBuffer)); @@ -237,7 +235,7 @@ bool ConnectionServer::decryptToken(const KeyShare::Token & token, char* session if (! retval) return retval; - memcpy(sessionKey, keyBufferPointer, apiSessionIdWidth); + memcpy(sessionKey, keyBufferPointer, sizeof(*keyBuffer)); keyBufferPointer += apiSessionIdWidth; memcpy(&stationId, keyBufferPointer, sizeof(StationId)); delete [] keyBuffer; @@ -912,7 +910,6 @@ void ConnectionServer::receiveMessage(const MessageDispatch::Emitter & source, c else if (message.isType("ExcommunicateGameServerMessage")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - ri = static_cast(message).getByteStream().begin(); ExcommunicateGameServerMessage msg(ri); LOG("GameGameConnect",("Told to drop connection to %lu by Central",msg.getServerId())); @@ -1040,7 +1037,7 @@ void ConnectionServer::run(void) Os::sleep(1); } - } while (!barrierReached && !cserver.done); + } while (!cserver.done); NetworkHandler::clearBytesThisFrame(); @@ -1418,7 +1415,6 @@ void ConnectionServer::installSessionValidation() void ConnectionServer::addToClientMap(const NetworkId &oid, ClientConnection* cconn) { Client * newClient = new Client(cconn, oid); - NOT_NULL(newClient); clientMap[oid] = newClient; diff --git a/engine/server/application/LoginServer/src/shared/LoginServer.cpp b/engine/server/application/LoginServer/src/shared/LoginServer.cpp index 1d018978..a38d3725 100644 --- a/engine/server/application/LoginServer/src/shared/LoginServer.cpp +++ b/engine/server/application/LoginServer/src/shared/LoginServer.cpp @@ -1171,19 +1171,17 @@ void LoginServer::run(void) } NetworkHandler::clearBytesThisFrame(); - if(mon) + + mon->set(WORLD_COUNT_CHANNEL, static_cast(getInstance().m_clientMap.size())); + int count = 0; + ClusterListType::const_iterator i; + for(i = getInstance().m_clusterList.begin(); i != getInstance().m_clusterList.end(); ++i) { - mon->set(WORLD_COUNT_CHANNEL, static_cast(getInstance().m_clientMap.size())); - int count = 0; - ClusterListType::const_iterator i; - for(i = getInstance().m_clusterList.begin(); i != getInstance().m_clusterList.end(); ++i) - { - if((*i)->m_connected) - ++count; - } - mon->set(CLUSTER_COUNT_CHANNEL, count); - mon->Update(); + if((*i)->m_connected) + ++count; } + mon->set(CLUSTER_COUNT_CHANNEL, count); + mon->Update(); } NetworkHandler::update(); @@ -1373,7 +1371,6 @@ void LoginServer::onValidateClient(StationId suid, const std::string & username, size_t len = sizeof(uint32) + sizeof(bool) + MAX_ACCOUNT_NAME_LENGTH + 1; unsigned char * keyBuffer = new unsigned char[len]; unsigned char * keyBufferPointer = keyBuffer; - NOT_NULL(keyBuffer); IGNORE_RETURN(memset(keyBuffer, 0, len)); diff --git a/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp b/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp index 62488a0a..d69a029c 100644 --- a/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp +++ b/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp @@ -703,7 +703,6 @@ void PlanetServer::receiveMessage(const MessageDispatch::Emitter & source, const else if (message.isType("ExcommunicateGameServerMessage")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - ri = static_cast(message).getByteStream().begin(); ExcommunicateGameServerMessage msg(ri); LOG("GameGameConnect",("Planet Server %s was told to drop connection to %lu by Central",Scene::getInstance().getSceneId().c_str(),msg.getServerId())); @@ -715,7 +714,6 @@ void PlanetServer::receiveMessage(const MessageDispatch::Emitter & source, const else if (message.isType("FactionalSystemMessage")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - ri = static_cast(message).getByteStream().begin(); FactionalSystemMessage msg(ri); // forward message to all game servers on this planet for processing @@ -725,7 +723,6 @@ void PlanetServer::receiveMessage(const MessageDispatch::Emitter & source, const else if (message.isType("MessageToPlayersOnPlanet")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage >, std::pair >, std::pair > > const msg(ri); // forward message to all game servers on this planet for processing diff --git a/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp b/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp index 7dbb911b..8fea5fdd 100644 --- a/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp @@ -4301,12 +4301,14 @@ static const int internalTagBufLen = strlen(internalTagBuf); do { newMod.mod.tag = Crc::calculate(&internalTagBuf[0]); - char * c = &internalTagBuf[internalTagBufLen-1]; - while (++(*c) == '9' + 1) - { - *c-- = '0'; + if ((internalTagBufLen - 1) > 0) { + char * c = &internalTagBuf[internalTagBufLen - 1]; + while (++(*c) == '9' + 1) + { + *c-- = '0'; + } + insertResult = m_attributeModList.insert(newMod.mod.tag, newMod); } - insertResult = m_attributeModList.insert(newMod.mod.tag, newMod); } while (!insertResult.second); // clear any flags that assume we have a valid tag. @@ -5488,13 +5490,6 @@ int CreatureObject::getInstrumentAudioId() const return audioId; } - // last, check the look at target if no weapon is equipped - if (!hasWeapon) - { - int audioId = internalGetInstrumentAudioId(getLookAtTarget()); - if(audioId) - return audioId; - } return 0; } diff --git a/engine/server/library/serverScript/src/shared/JavaLibrary.cpp b/engine/server/library/serverScript/src/shared/JavaLibrary.cpp index 2ae597df..24c28a00 100644 --- a/engine/server/library/serverScript/src/shared/JavaLibrary.cpp +++ b/engine/server/library/serverScript/src/shared/JavaLibrary.cpp @@ -1283,6 +1283,7 @@ void JavaLibrary::initializeJavaThread() strcpy(profileBuffer,"-Xrunhprof:cpu=times"); tempOption.optionString = profileBuffer; options.push_back(tempOption); + delete [] profileBuffer; } else { diff --git a/engine/shared/library/sharedDebug/src/shared/RemoteDebug_inner.cpp b/engine/shared/library/sharedDebug/src/shared/RemoteDebug_inner.cpp index 39aa3a54..3da8b8be 100644 --- a/engine/shared/library/sharedDebug/src/shared/RemoteDebug_inner.cpp +++ b/engine/shared/library/sharedDebug/src/shared/RemoteDebug_inner.cpp @@ -92,7 +92,7 @@ RemoteDebug::Variable::Variable(const std::string& name, void *memLoc, VARIABLE_ break; case CSTRING: - m_value.stringValue = &s; + m_value.stringValue = s; break; case BOOL: diff --git a/engine/shared/library/sharedFile/src/shared/FileStreamer.cpp b/engine/shared/library/sharedFile/src/shared/FileStreamer.cpp index 6c47b26c..18f57271 100644 --- a/engine/shared/library/sharedFile/src/shared/FileStreamer.cpp +++ b/engine/shared/library/sharedFile/src/shared/FileStreamer.cpp @@ -229,7 +229,7 @@ int FileStreamer::File::read(int offset, void *destinationBuffer, int numberOfBy newRequest->bytesRead = 0; newRequest->gate = gate; newRequest->priority = priority; - newRequest->returnValue = &returnValue; + newRequest->returnValue = returnValue; // submit the request FileStreamerThread::submitRequest(newRequest); diff --git a/engine/shared/library/sharedFile/src/shared/FileStreamerThread.h b/engine/shared/library/sharedFile/src/shared/FileStreamerThread.h index 1d9787b7..1431c78a 100644 --- a/engine/shared/library/sharedFile/src/shared/FileStreamerThread.h +++ b/engine/shared/library/sharedFile/src/shared/FileStreamerThread.h @@ -115,7 +115,7 @@ public: AbstractFile::PriorityType priority; // storage held by game thread used to pass back return value - int *returnValue; + int returnValue; public: diff --git a/engine/shared/library/sharedFile/src/shared/Iff.cpp b/engine/shared/library/sharedFile/src/shared/Iff.cpp index abe766d1..212ef576 100644 --- a/engine/shared/library/sharedFile/src/shared/Iff.cpp +++ b/engine/shared/library/sharedFile/src/shared/Iff.cpp @@ -604,7 +604,6 @@ void Iff::adjustDataAsNeeded(int size) // allocate the new memory DEBUG_FATAL(newLength < 0, ("negative array allocation")); byte *newData = new byte[static_cast(newLength)]; - NOT_NULL(newData); // copy the old data over to the new data memcpy(newData, data, stack[0].length); diff --git a/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocument.cpp b/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocument.cpp index 2ae18c8d..2a6d91d0 100644 --- a/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocument.cpp +++ b/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocument.cpp @@ -97,8 +97,6 @@ XmlTreeDocument* XmlTreeDocument::createDocument(const char * rootNodeName) xmlDocSetRootElement(doc, node); XmlTreeDocument *treeDoc = new XmlTreeDocument(doc); - - DEBUG_WARNING( !treeDoc, ("Attempted to make new XmlTreeDoc but failed") ); xmlFree(doc); return 0; diff --git a/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp b/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp index 8abd18a9..1252919d 100644 --- a/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp +++ b/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp @@ -525,10 +525,7 @@ stringMessage::stringMessage(const unsigned short command,const unsigned short s monMessage(command, sequence, size) { data = new char [strlen(newData) + 1]; - if (data) - strncpy(data, newData, strlen(newData + 1)); - else - data = NULL; + strncpy(data, newData, strlen(newData + 1)); } //---------------------------------------------------------------- @@ -561,14 +558,9 @@ dataReplyMessage::dataReplyMessage(const unsigned char * source) : monMessage(source) { data = new unsigned char[getSize()+1]; - - if (data) - { - memcpy(data, source + 6, getSize()); - data[getSize()] = 0; - } - else - data = NULL; + + memcpy(data, source + 6, getSize()); + data[getSize()] = 0; } //---------------------------------------------------------------- @@ -589,11 +581,8 @@ monMessage(command, sequence, size) //---------------------------------------------------------------- dataReplyMessage::~dataReplyMessage() { - if (data) - { - delete [] data; - data = 0; - } + delete [] data; + data = 0; } //---------------------------------------------------------------- diff --git a/external/3rd/library/platform/projects/MonAPI2/MonitorData.cpp b/external/3rd/library/platform/projects/MonAPI2/MonitorData.cpp index bd417941..b897b5cd 100644 --- a/external/3rd/library/platform/projects/MonAPI2/MonitorData.cpp +++ b/external/3rd/library/platform/projects/MonAPI2/MonitorData.cpp @@ -520,9 +520,10 @@ int high, i, low; if ( high < m_count && Id==m_data[high].id ) { - if( m_data[high].ChangedTime == 0 || m_data[high].value != value ) - m_data[high].ChangedTime = (long)time(NULL); - m_data[high].value = value; + if (m_data[high].ChangedTime == 0 || m_data[high].value != value) { + m_data[high].ChangedTime = (long)time(NULL); + m_data[high].value = value; + } } } diff --git a/external/3rd/library/platform/utils/Base/Config.cpp b/external/3rd/library/platform/utils/Base/Config.cpp index 6dbe93b9..2edbca45 100644 --- a/external/3rd/library/platform/utils/Base/Config.cpp +++ b/external/3rd/library/platform/utils/Base/Config.cpp @@ -43,12 +43,6 @@ bool CConfig::LoadFile(char * file) // allocate buffer pConfig = new char[length + 1]; - if (pConfig == NULL) - { - fclose(fp); - fprintf(stderr,"Failed to alloc config buffer length %d",(int32)length); - return false; - } memset(pConfig,0,length); // read data, stripping comments diff --git a/external/3rd/library/platform/utils/Base/ScopeLock.h b/external/3rd/library/platform/utils/Base/ScopeLock.h index c965b78f..d16c31d0 100644 --- a/external/3rd/library/platform/utils/Base/ScopeLock.h +++ b/external/3rd/library/platform/utils/Base/ScopeLock.h @@ -26,7 +26,6 @@ namespace Base CScopeLock(CMutex& mutex); CScopeLock(CScopeLock& lock); virtual ~CScopeLock(); - private: CMutex *mMutex; }; diff --git a/external/3rd/library/soePlatform/CSAssist/projects/CSAssist/CSAssistgameapi/response.cpp b/external/3rd/library/soePlatform/CSAssist/projects/CSAssist/CSAssistgameapi/response.cpp index 2d96b0a8..cd307d8f 100644 --- a/external/3rd/library/soePlatform/CSAssist/projects/CSAssist/CSAssistgameapi/response.cpp +++ b/external/3rd/library/soePlatform/CSAssist/projects/CSAssist/CSAssistgameapi/response.cpp @@ -204,12 +204,6 @@ void ResGetTicketComments::decode(Base::ByteStream::ReadIterator &msg) if (mNumberRead > 0) { mCommentArray = new CSAssistGameAPITicketComment[mNumberRead]; - if (mCommentArray == 0) // memory allocation error, return error code - { - mNumberRead = 0; - setResult(CSASSIST_RESULT_OUTOFMEMORY); - return; - } CSAssistGameAPITicketComment *pcomments = mCommentArray; for (unsigned i=0; i < mNumberRead; i++) { @@ -245,13 +239,6 @@ void ResGetTicketByCharacter::decode(Base::ByteStream::ReadIterator &msg) if (mNumberReturned > 0) { mTicketArray = new CSAssistGameAPITicket[mNumberReturned]; - if (mTicketArray == 0) // memory allocation error, return error code - { - mNumberReturned = 0; - mTotalNumber = 0; - setResult(CSASSIST_RESULT_OUTOFMEMORY); - return; - } CSAssistGameAPITicket *ptickets = mTicketArray; for (unsigned i=0; i < mNumberReturned; i++) { @@ -389,12 +376,6 @@ void ResGetDocumentList::decode(Base::ByteStream::ReadIterator &msg) if (mNumberRead > 0) { mDocumentArray = new CSAssistGameAPIDocumentHeader[mNumberRead]; - if (mDocumentArray == 0) // memory allocation error, return error code - { - mNumberRead = 0; - setResult(CSASSIST_RESULT_OUTOFMEMORY); - return; - } CSAssistGameAPIDocumentHeader *pdocs = mDocumentArray; for (unsigned i=0; i < mNumberRead; i++) { @@ -506,12 +487,6 @@ void ResSearchKB::decode(Base::ByteStream::ReadIterator &msg) if (mNumberRead > 0) { mArticleArray = new CSAssistGameAPISearchResult[mNumberRead]; - if (mArticleArray == 0) // memory allocation error, return error code - { - mNumberRead = 0; - setResult(CSASSIST_RESULT_OUTOFMEMORY); - return; - } CSAssistGameAPISearchResult *pdocs = mArticleArray; for (unsigned i=0; i < mNumberRead; i++) { diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/Config.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/Config.cpp index 1b9e61fb..6c963ff1 100644 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/Config.cpp +++ b/external/3rd/library/soePlatform/CSAssist/utils/Base/Config.cpp @@ -42,12 +42,6 @@ bool CConfig::LoadFile(char * file) // allocate buffer pConfig = new char[length + 1]; - if (pConfig == NULL) - { - fclose(fp); - fprintf(stderr,"Failed to alloc config buffer length %d",(int32)length); - return false; - } memset(pConfig,0,length); // read data, stripping comments diff --git a/external/3rd/library/soePlatform/CSAssist/utils/TcpLibrary/TcpManager.h b/external/3rd/library/soePlatform/CSAssist/utils/TcpLibrary/TcpManager.h index 75eb6df4..32132069 100644 --- a/external/3rd/library/soePlatform/CSAssist/utils/TcpLibrary/TcpManager.h +++ b/external/3rd/library/soePlatform/CSAssist/utils/TcpLibrary/TcpManager.h @@ -18,8 +18,8 @@ #include #include #include - const int INVALID_SOCKET = 0xFFFFFFFF; - const int SOCKET_ERROR = 0xFFFFFFFF; + const unsigned long int INVALID_SOCKET = 0xFFFFFFFF; + const unsigned long int SOCKET_ERROR = 0xFFFFFFFF; typedef int SOCKET; #endif diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Unicode/utf8.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Unicode/utf8.cpp index a4634187..527f246d 100644 --- a/external/3rd/library/soePlatform/CSAssist/utils/Unicode/utf8.cpp +++ b/external/3rd/library/soePlatform/CSAssist/utils/Unicode/utf8.cpp @@ -217,12 +217,11 @@ Plat_Unicode::String UTF8ToUnicode(const char *source) Plat_Unicode::String s = narrowToWide(""); int length = strlen(source) + 1; UTF16 *buffer = new UTF16[length]; - if (buffer != NULL) - { - UTF8_convertToUTF16(const_cast(source) , buffer, length); - s =buffer; - delete [] buffer; - } + + UTF8_convertToUTF16(const_cast(source) , buffer, length); + s =buffer; + delete [] buffer; + return s; } diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/Config.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/Config.cpp index 359af5e7..a6bfab4d 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/Config.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Base/Config.cpp @@ -41,13 +41,6 @@ bool CConfig::LoadFile(char * file) // allocate buffer pConfig = new char[length + 1]; - - if (pConfig == NULL) - { - fclose(fp); - fprintf(stderr,"Failed to alloc config buffer length %d",(int32)length); - return false; - } memset(pConfig,0,length); // read data, stripping comments diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/utf8.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/utf8.cpp index a4634187..da8e34e8 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/utf8.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/utf8.cpp @@ -217,12 +217,10 @@ Plat_Unicode::String UTF8ToUnicode(const char *source) Plat_Unicode::String s = narrowToWide(""); int length = strlen(source) + 1; UTF16 *buffer = new UTF16[length]; - if (buffer != NULL) - { - UTF8_convertToUTF16(const_cast(source) , buffer, length); - s =buffer; - delete [] buffer; - } + UTF8_convertToUTF16(const_cast(source) , buffer, length); + s =buffer; + delete [] buffer; + return s; } diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp index aac02947..5fac3118 100644 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp @@ -569,10 +569,7 @@ dataReplyMessage::dataReplyMessage(const unsigned short command, monMessage(command, sequence, size) { data = new unsigned char[newDataLen]; - if (data) - memcpy(data, newData, newDataLen); - else - data = NULL; + memcpy(data, newData, newDataLen); } //----------------------------------------------------------------