From 3398938d31b2c119cf2eb2169148ad88682251bc Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 27 Nov 2011 19:12:18 -0800 Subject: [PATCH] Fix a bunch of warnings from clang. --- .../Apps/plPythonPack/PythonInterface.cpp | 7 +++--- .../Apps/plPythonPack/PythonInterface.h | 9 +++---- Sources/Plasma/Apps/plPythonPack/main.cpp | 20 +++++++--------- Sources/Plasma/CoreLib/hsCritSect.cpp | 2 +- Sources/Plasma/CoreLib/hsFastMath.cpp | 4 ++-- Sources/Plasma/CoreLib/hsStringTokenizer.cpp | 20 ++++++++-------- Sources/Plasma/CoreLib/hsTemplates.h | 1 + Sources/Plasma/CoreLib/hsWide.h | 10 ++++---- .../NucleusLib/pnDispatch/plDispatch.cpp | 4 ++-- .../Plasma/NucleusLib/pnDispatch/plDispatch.h | 6 ++--- .../NucleusLib/pnKeyedObject/plUoid.cpp | 2 +- .../pnSceneObject/plCoordinateInterface.cpp | 4 ++-- .../pnSceneObject/plSceneObject.cpp | 6 ++--- Sources/Plasma/NucleusLib/pnTimer/hsTimer.cpp | 2 ++ .../plClientResMgr/plClientResMgr.cpp | 2 +- .../plClientResMgr/plClientResMgr.h | 2 +- .../PubUtilLib/plContainer/plConfigInfo.cpp | 24 +++++++++---------- .../plContainer/plKeysAndValues.cpp | 6 +++-- .../Plasma/PubUtilLib/plFile/plFileUtils.cpp | 22 +++++++++-------- .../PubUtilLib/plGImage/plDynamicTextMap.cpp | 2 +- .../Plasma/PubUtilLib/plGImage/plMipmap.cpp | 8 +++---- .../PubUtilLib/plInterp/plAnimTimeConvert.cpp | 8 +++---- .../PubUtilLib/plInterp/plController.cpp | 2 +- .../plParticleSystem/plParticleEffect.cpp | 2 +- .../plParticleSystem/plParticleSystem.cpp | 16 ++++++------- .../PubUtilLib/plResMgr/plBSDiffBuffer.cpp | 4 ++-- .../PubUtilLib/plResMgr/plKeyFinder.cpp | 2 +- Sources/Plasma/PubUtilLib/plSDL/plSDL.h | 2 +- .../PubUtilLib/plSDL/plStateVariable.cpp | 9 ++++--- .../PubUtilLib/plStatusLog/plStatusLog.cpp | 4 ++-- .../PubUtilLib/plSurface/plLayerAnimation.cpp | 4 ++-- .../PubUtilLib/plTransform/mat_decomp.cpp | 4 ++-- 32 files changed, 114 insertions(+), 106 deletions(-) diff --git a/Sources/Plasma/Apps/plPythonPack/PythonInterface.cpp b/Sources/Plasma/Apps/plPythonPack/PythonInterface.cpp index 5bfbd5c7..d6db9154 100644 --- a/Sources/Plasma/Apps/plPythonPack/PythonInterface.cpp +++ b/Sources/Plasma/Apps/plPythonPack/PythonInterface.cpp @@ -39,7 +39,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ -#include "hsTypes.h" #include "PythonInterface.h" #include "compile.h" @@ -139,7 +138,7 @@ void PythonInterface::finiPython() // // PURPOSE : run a python string in a specific module name // -PyObject* PythonInterface::CompileString(char *command, char* filename) +PyObject* PythonInterface::CompileString(const char *command, const char* filename) { PyObject* pycode = Py_CompileString(command, filename, Py_file_input); return pycode; @@ -220,7 +219,7 @@ int PythonInterface::getOutputAndReset(char** line) // // PURPOSE : create a new module with built-ins // -PyObject* PythonInterface::CreateModule(char* module) +PyObject* PythonInterface::CreateModule(const char* module) { PyObject *m, *d; // first we must get rid of any old modules of the same name, we'll replace it @@ -291,7 +290,7 @@ hsBool PythonInterface::RunPYC(PyObject* code, PyObject* module) // // PURPOSE : get an item (probably a function) from a specific module // -PyObject* PythonInterface::GetModuleItem(char* item, PyObject* module) +PyObject* PythonInterface::GetModuleItem(const char* item, PyObject* module) { if ( module ) { diff --git a/Sources/Plasma/Apps/plPythonPack/PythonInterface.h b/Sources/Plasma/Apps/plPythonPack/PythonInterface.h index 80db724a..8956a330 100644 --- a/Sources/Plasma/Apps/plPythonPack/PythonInterface.h +++ b/Sources/Plasma/Apps/plPythonPack/PythonInterface.h @@ -39,7 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ -#include "Python.h" +#include +#include "hsTypes.h" #include @@ -50,10 +51,10 @@ namespace PythonInterface // So the Python packer can add extra paths void addPythonPath(std::string dir); - PyObject* CompileString(char *command, char* filename); + PyObject* CompileString(const char *command, const char* filename); hsBool DumpObject(PyObject* pyobj, char** pickle, Int32* size); int getOutputAndReset(char** line=nil); - PyObject* CreateModule(char* module); + PyObject* CreateModule(const char* module); hsBool RunPYC(PyObject* code, PyObject* module); - PyObject* GetModuleItem(char* item, PyObject* module); + PyObject* GetModuleItem(const char* item, PyObject* module); } diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index 2fc5af5e..56940d57 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -39,11 +39,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ +#include "PythonInterface.h" + #include "hsStream.h" #include "plFile/hsFiles.h" -#include "PythonInterface.h" - #include #include #include @@ -123,14 +123,14 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s) } // import the module first, to make packages work correctly - PyImport_ImportModule((char*)fileName.c_str()); - PyObject* pythonCode = PythonInterface::CompileString(code, (char*)fileName.c_str()); + PyImport_ImportModule(fileName.c_str()); + PyObject* pythonCode = PythonInterface::CompileString(code, fileName.c_str()); if (pythonCode) { // we need to find out if this is PythonFile module // create a module name... with the '.' as an X // and create a python file name that is without the ".py" - PyObject* fModule = PythonInterface::CreateModule((char*)fileName.c_str()); + PyObject* fModule = PythonInterface::CreateModule(fileName.c_str()); // run the code if (PythonInterface::RunPYC(pythonCode, fModule) ) { @@ -166,7 +166,7 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s) // else // skip the CRs } - pythonCode = PythonInterface::CompileString(code, (char*)fileName.c_str()); + pythonCode = PythonInterface::CompileString(code, fileName.c_str()); hsAssert(pythonCode,"Not sure why this didn't compile the second time???"); printf("an import file "); } @@ -181,8 +181,7 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s) int chars_read = PythonInterface::getOutputAndReset(&errmsg); if (chars_read > 0) { - printf(errmsg); - printf("\n"); + printf("%s\n", errmsg); } } } @@ -200,8 +199,7 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s) int chars_read = PythonInterface::getOutputAndReset(&errmsg); if (chars_read > 0) { - printf(errmsg); - printf("\n"); + printf("%s\n", errmsg); } s->WriteLE32(size); s->Write(size, pycode); @@ -218,7 +216,7 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s) int chars_read = PythonInterface::getOutputAndReset(&errmsg); if (chars_read > 0) { - printf(errmsg); + printf("%s\n", errmsg); } } diff --git a/Sources/Plasma/CoreLib/hsCritSect.cpp b/Sources/Plasma/CoreLib/hsCritSect.cpp index 93e299b5..fc02123f 100644 --- a/Sources/Plasma/CoreLib/hsCritSect.cpp +++ b/Sources/Plasma/CoreLib/hsCritSect.cpp @@ -83,7 +83,7 @@ void CCritSect::Leave () { #elif HS_BUILD_FOR_UNIX //=========================================================================== CCritSect::CCritSect () { - m_handle = PTHREAD_MUTEX_INITIALIZER; + m_handle = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER; } //=========================================================================== diff --git a/Sources/Plasma/CoreLib/hsFastMath.cpp b/Sources/Plasma/CoreLib/hsFastMath.cpp index b3737f89..d6e679b4 100644 --- a/Sources/Plasma/CoreLib/hsFastMath.cpp +++ b/Sources/Plasma/CoreLib/hsFastMath.cpp @@ -606,8 +606,8 @@ hsScalar hsFastMath::IATan2OverTwoPi(hsScalar y, hsScalar x) return 0; hsBool xNeg, yNeg; - if( yNeg = (y < 0) )y = -y; - if( xNeg = (x < 0) )x = -x; + if((yNeg = (y < 0)))y = -y; + if((xNeg = (x < 0)))x = -x; hsBool yBigger = y >= x; hsScalar div = yBigger ? x / y : y / x; diff --git a/Sources/Plasma/CoreLib/hsStringTokenizer.cpp b/Sources/Plasma/CoreLib/hsStringTokenizer.cpp index 8ba12996..b219d542 100644 --- a/Sources/Plasma/CoreLib/hsStringTokenizer.cpp +++ b/Sources/Plasma/CoreLib/hsStringTokenizer.cpp @@ -57,8 +57,8 @@ fLastTerminator(nil) hsStringTokenizer::~hsStringTokenizer() { - delete [] fString; - delete [] fSeps; + delete[] fString; + delete[] fSeps; } hsBool hsStringTokenizer::HasMoreTokens() @@ -134,11 +134,11 @@ void hsStringTokenizer::RestoreLastTerminator( void ) void hsStringTokenizer::Reset(const char *string, const char *seps) { if (fString) - delete [] fString; + delete[] fString; fString = string ? hsStrcpy(string) : nil; if (fSeps) - delete [] fSeps; + delete[] fSeps; fSeps = seps ? hsStrcpy(seps) : nil; fNumSeps = fSeps ? strlen(fSeps) : 0; fCheckAlphaNum = false; @@ -181,8 +181,8 @@ hsWStringTokenizer::hsWStringTokenizer(const wchar *string, const wchar *seps) : hsWStringTokenizer::~hsWStringTokenizer() { - delete [] fString; - delete [] fSeps; + delete[] fString; + delete[] fSeps; } hsBool hsWStringTokenizer::HasMoreTokens() @@ -259,11 +259,11 @@ void hsWStringTokenizer::RestoreLastTerminator( void ) void hsWStringTokenizer::Reset(const wchar *string, const wchar *seps) { if (fString) - delete [] fString; + delete[] fString; if (string) { int count = wcslen(string); - fString = TRACKED_NEW(wchar[count + 1]); + fString = new wchar[count + 1]; wcscpy(fString, string); fString[count] = L'\0'; } @@ -271,11 +271,11 @@ void hsWStringTokenizer::Reset(const wchar *string, const wchar *seps) fString = nil; if (fSeps) - delete [] fSeps; + delete[] fSeps; if (seps) { int count = wcslen(seps); - fSeps = TRACKED_NEW(wchar[count + 1]); + fSeps = new wchar[count + 1]; wcscpy(fSeps, seps); fSeps[count] = L'\0'; } diff --git a/Sources/Plasma/CoreLib/hsTemplates.h b/Sources/Plasma/CoreLib/hsTemplates.h index f36bea0d..f3fb29b3 100644 --- a/Sources/Plasma/CoreLib/hsTemplates.h +++ b/Sources/Plasma/CoreLib/hsTemplates.h @@ -524,6 +524,7 @@ public: UInt16 GetNumAlloc() const { return fTotalCount; } }; +template void hsTArray_CopyForward(const T src[], T dst[], int count); template class hsTArray : public hsTArrayBase { diff --git a/Sources/Plasma/CoreLib/hsWide.h b/Sources/Plasma/CoreLib/hsWide.h index 132c87ed..cfd3ca88 100644 --- a/Sources/Plasma/CoreLib/hsWide.h +++ b/Sources/Plasma/CoreLib/hsWide.h @@ -58,8 +58,8 @@ struct hsWide { hsBool operator==(const hsWide& b) const { return fHi == b.fHi && fLo == b.fLo; } - hsBool operator<(const hsWide& b) const { return fHi < b.fHi || fHi == b.fHi && fLo < b.fLo; } - hsBool operator>( const hsWide& b) const { return fHi > b.fHi || fHi == b.fHi && fLo > b.fLo; } + hsBool operator<(const hsWide& b) const { return fHi < b.fHi || (fHi == b.fHi && fLo < b.fLo); } + hsBool operator>( const hsWide& b) const { return fHi > b.fHi || (fHi == b.fHi && fLo > b.fLo); } hsBool operator!=( const hsWide& b) const { return !( *this == b); } hsBool operator<=(const hsWide& b) const { return !(*this > b); } hsBool operator>=(const hsWide& b) const { return !(*this < b); } @@ -187,11 +187,11 @@ inline hsWide* hsWide::RoundRight(unsigned shift) inline Int32 hsWide::AsLong() const { #if HS_PIN_MATH_OVERFLOW - if (fHi > 0 || fHi == 0 && (Int32)fLo < 0) + if (fHi > 0 || (fHi == 0 && (Int32)fLo < 0)) { hsSignalMathOverflow(); return kPosInfinity32; } - if (fHi < -1L || fHi == -1L && (Int32)fLo >= 0) + if (fHi < -1L || (fHi == -1L && (Int32)fLo >= 0)) { hsSignalMathOverflow(); return kNegInfinity32; } @@ -201,7 +201,7 @@ inline Int32 hsWide::AsLong() const inline hsBool hsWide::IsWide() const { - return (fHi > 0 || fHi == 0 && (Int32)fLo < 0) || (fHi < -1L || fHi == -1L && (Int32)fLo >= 0); + return (fHi > 0 || (fHi == 0 && (Int32)fLo < 0)) || (fHi < -1L || (fHi == -1L && (Int32)fLo >= 0)); } inline hsFixed hsWide::AsFixed() const diff --git a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp index 2d53c76c..78814c0d 100644 --- a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp +++ b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp @@ -286,7 +286,7 @@ void plDispatch::IMsgDispatch() fMsgCurrentMutex.Lock(); plMsgWrap* origTail = fMsgTail; - while( fMsgCurrent = fMsgHead ) + while((fMsgCurrent = fMsgHead)) { IDequeue(&fMsgHead, &fMsgTail); fMsgCurrentMutex.Unlock(); @@ -460,7 +460,7 @@ hsBool plDispatch::MsgSend(plMessage* msg, hsBool async) plTimeMsg* timeMsg; if( msg->GetTimeStamp() > hsTimer::GetSysSeconds() ) return ISortToDeferred(msg); - else if( timeMsg = plTimeMsg::ConvertNoRef(msg) ) + else if((timeMsg = plTimeMsg::ConvertNoRef(msg))) ICheckDeferred(timeMsg->DSeconds()); plMsgWrap* msgWrap = TRACKED_NEW plMsgWrap(msg); diff --git a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h index 43fb794f..ac55e69e 100644 --- a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h +++ b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h @@ -145,9 +145,9 @@ public: virtual void UnRegisterForType(UInt16 hClass, const plKey& receiver) {} - virtual hsBool MsgSend(plMessage* msg) {} - virtual void MsgQueue(plMessage* msg){} - virtual void MsgQueueProcess(){} + virtual hsBool MsgSend(plMessage* msg) { return true; } + virtual void MsgQueue(plMessage* msg) {} + virtual void MsgQueueProcess() {} }; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp index d8494838..d870b6f7 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp @@ -274,7 +274,7 @@ plUoid& plUoid::operator=(const plUoid& rhs) // THIS SHOULD BE FOR DEBUGGING ONLY char* plUoid::StringIze(char* str) const // Format to displayable string { - sprintf(str, "(0x%x:0x%x:%s:C:[%lu,%lu])", + sprintf(str, "(0x%x:0x%x:%s:C:[%u,%u])", fLocation.GetSequenceNumber(), int(fLocation.GetFlags()), fObjectName, diff --git a/Sources/Plasma/NucleusLib/pnSceneObject/plCoordinateInterface.cpp b/Sources/Plasma/NucleusLib/pnSceneObject/plCoordinateInterface.cpp index 42c8ac56..9adddaf5 100644 --- a/Sources/Plasma/NucleusLib/pnSceneObject/plCoordinateInterface.cpp +++ b/Sources/Plasma/NucleusLib/pnSceneObject/plCoordinateInterface.cpp @@ -602,7 +602,7 @@ hsBool plCoordinateInterface::MsgReceive(plMessage* msg) ITransformChanged(false, kReasonUnknown, false); return true; } - else if( intRefMsg = plIntRefMsg::ConvertNoRef(msg) ) + else if((intRefMsg = plIntRefMsg::ConvertNoRef(msg))) { switch( intRefMsg->fType ) { @@ -641,7 +641,7 @@ hsBool plCoordinateInterface::MsgReceive(plMessage* msg) break; } } - else if( corrMsg = plCorrectionMsg::ConvertNoRef(msg) ) + else if((corrMsg = plCorrectionMsg::ConvertNoRef(msg))) { SetTransformPhysical(corrMsg->fLocalToWorld, corrMsg->fWorldToLocal); diff --git a/Sources/Plasma/NucleusLib/pnSceneObject/plSceneObject.cpp b/Sources/Plasma/NucleusLib/pnSceneObject/plSceneObject.cpp index 282155f4..fe6091e5 100644 --- a/Sources/Plasma/NucleusLib/pnSceneObject/plSceneObject.cpp +++ b/Sources/Plasma/NucleusLib/pnSceneObject/plSceneObject.cpp @@ -488,7 +488,7 @@ hsBool plSceneObject::MsgReceive(plMessage* msg) return true; } else - if( trans = plTransformMsg::ConvertNoRef(msg) ) // also catches the derived plDelayedTransformMsg + if((trans = plTransformMsg::ConvertNoRef(msg))) // also catches the derived plDelayedTransformMsg { if( fCoordinateInterface ) { @@ -498,7 +498,7 @@ hsBool plSceneObject::MsgReceive(plMessage* msg) return true; } else - if( att = plAttachMsg::ConvertNoRef(msg) ) + if((att = plAttachMsg::ConvertNoRef(msg))) { if( fCoordinateInterface ) { @@ -883,4 +883,4 @@ void plSceneObject::AddModifier(plModifier* mo) void plSceneObject::RemoveModifier(plModifier* mo) { IRemoveModifier(mo); -} \ No newline at end of file +} diff --git a/Sources/Plasma/NucleusLib/pnTimer/hsTimer.cpp b/Sources/Plasma/NucleusLib/pnTimer/hsTimer.cpp index f3026adf..ead7aad1 100644 --- a/Sources/Plasma/NucleusLib/pnTimer/hsTimer.cpp +++ b/Sources/Plasma/NucleusLib/pnTimer/hsTimer.cpp @@ -308,6 +308,8 @@ UInt32 hsTimer::GetPrecTickCount() return GetTickCount(); return ti.LowPart; +#else + return 1; #endif } UInt32 hsTimer::PrecSecsToTicks(hsScalar secs) diff --git a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp index f79b5ded..adc8cff0 100644 --- a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp @@ -1,4 +1,4 @@ -/*==LICENSE==* +/*==LICENSE==* CyanWorlds.com Engine - MMOG client, server and tools Copyright (C) 2011 Cyan Worlds, Inc. diff --git a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h index 842d855d..f3c16b73 100644 --- a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h +++ b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h @@ -1,4 +1,4 @@ -/*==LICENSE==* +/*==LICENSE==* CyanWorlds.com Engine - MMOG client, server and tools Copyright (C) 2011 Cyan Worlds, Inc. diff --git a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp index f2aee940..01901b0a 100644 --- a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp @@ -670,14 +670,14 @@ bool plIniConfigSource::WriteOutOf(plConfigInfo & configInfo) plConfigInfo::Values::const_iterator vi, ve; fConfigInfo->GetSectionIterators(si,se); - for (si; si!=se; ++si) + for (; si!=se; ++si) { file << std::endl << "[" << si->first.c_str() << "]"<< std::endl; if (fConfigInfo->GetKeyIterators(si->first, ki, ke)) - for (ki; ki!=ke; ++ki) + for (; ki!=ke; ++ki) { if (fConfigInfo->GetValueIterators(si->first, ki->first, vi, ve)) - for (vi; vi!=ve; ++vi) + for (; vi!=ve; ++vi) { file << ki->first.c_str() << "=" << vi->c_str() << std::endl; } @@ -738,14 +738,14 @@ bool plIniStreamConfigSource::WriteOutOf(plConfigInfo & configInfo) plConfigInfo::Values::const_iterator vi, ve; fConfigInfo->GetSectionIterators(si,se); - for (si; si!=se; ++si) + for (; si!=se; ++si) { ss << std::endl << "[" << si->first.c_str() << "]"<< std::endl; if (fConfigInfo->GetKeyIterators(si->first, ki, ke)) - for (ki; ki!=ke; ++ki) + for (; ki!=ke; ++ki) { if (fConfigInfo->GetValueIterators(si->first, ki->first, vi, ve)) - for (vi; vi!=ve; ++vi) + for (; vi!=ve; ++vi) { ss << ki->first.c_str() << "=" << vi->c_str() << std::endl; } @@ -887,13 +887,13 @@ bool plIniNoSectionsConfigSource::WriteOutOf(plConfigInfo & configInfo) plConfigInfo::Values::const_iterator vi, ve; fConfigInfo->GetSectionIterators(si,se); - for (si; si!=se; ++si) + for (; si!=se; ++si) { if (fConfigInfo->GetKeyIterators(si->first, ki, ke)) - for (ki; ki!=ke; ++ki) + for (; ki!=ke; ++ki) { if (fConfigInfo->GetValueIterators(si->first, ki->first, vi, ve)) - for (vi; vi!=ve; ++vi) + for (; vi!=ve; ++vi) { file << ki->first.c_str() << "=" << vi->c_str() << std::endl; } @@ -919,15 +919,15 @@ bool plDebugConfigSource::WriteOutOf(plConfigInfo & configInfo) char buf[1024]; fConfigInfo->GetSectionIterators(si,se); - for (si; si!=se; ++si) + for (; si!=se; ++si) { sprintf(buf,"\n[%s]\n",si->first.c_str()); hsStatusMessage(buf); if (fConfigInfo->GetKeyIterators(si->first, ki, ke)) - for (ki; ki!=ke; ++ki) + for (; ki!=ke; ++ki) { if (fConfigInfo->GetValueIterators(si->first, ki->first, vi, ve)) - for (vi; vi!=ve; ++vi) + for (; vi!=ve; ++vi) { sprintf(buf,"%s=%s\n",ki->first.c_str(),vi->c_str()); hsStatusMessage(buf); diff --git a/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp b/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp index 51848422..6be46c26 100644 --- a/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp +++ b/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp @@ -111,6 +111,8 @@ bool plKeysAndValues::AddValue(const std::string & key, const std::string & valu if (HasKey(key)) RemoveKey(key); break; + default: + break; } fKeys[key.c_str()].push_front(value.c_str()); return true; @@ -259,7 +261,7 @@ void plKeysAndValues::Write(hsStream * s) // iterate through keys Keys::const_iterator ki,ke; GetKeyIterators(ki,ke); - for (ki;ki!=ke;++ki) + for (;ki!=ke;++ki) { // write key string s->WriteLE((UInt16)ki->first.size()); @@ -269,7 +271,7 @@ void plKeysAndValues::Write(hsStream * s) // iterate through values for this key Values::const_iterator vi,ve; GetValueIterators(ki->first,vi,ve); - for (vi;vi!=ve;++vi) + for (;vi!=ve;++vi) { // write value string s->WriteLE((UInt16)vi->size()); diff --git a/Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp b/Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp index d54035db..9140f8c7 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp @@ -104,8 +104,10 @@ hsBool plFileUtils::CreateDir( const wchar *path ) return ( _wmkdir( path ) == 0 ) ? true : ( errno==EEXIST ); #elif HS_BUILD_FOR_UNIX const char* cpath = hsWStringToString(path); - CreateDir(cpath); + bool ret = CreateDir(cpath); delete[] cpath; /* Free the string */ + + return ret; #endif } @@ -156,8 +158,10 @@ bool plFileUtils::RemoveFile(const wchar* filename, bool delReadOnly) return (_wunlink(filename) == 0); #elif HS_BUILD_FOR_UNIX const char* cfilename = hsWStringToString(filename); - RemoveFile(cfilename, delReadOnly); + bool ret = RemoveFile(cfilename, delReadOnly); delete[] cfilename; /* Free the string */ + + return ret; #endif } @@ -542,13 +546,11 @@ bool plFileUtils::GetSecureEncryptionKey(const wchar* filename, UInt32* key, uns return true; } - else - { - // file doesn't exist, use default key - unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey)); - memSize *= sizeof(UInt32); - memcpy(key, plSecureStream::kDefaultKey, memSize); - return false; - } + // file doesn't exist, use default key + unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey)); + memSize *= sizeof(UInt32); + memcpy(key, plSecureStream::kDefaultKey, memSize); + + return false; } diff --git a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp index 780f407e..3e97bcf6 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp @@ -251,7 +251,7 @@ void plDynamicTextMap::IDestroyOSSurface( void ) IRemoveFromMemRecord( (UInt8 *)fImage ); #endif - delete [] fImage; + delete[] (UInt32*)fImage; fImage = nil; plProfile_Dec(DynaTexts); diff --git a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp index 9320d70d..d365dcfc 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp @@ -180,7 +180,7 @@ void plMipmap::Reset() IRemoveFromMemRecord( (UInt8 *)fImage ); #endif - delete [] fImage; + delete[] (UInt8*)fImage; plProfile_DelMem(MemMipmaps, fTotalSize); } fImage = nil; @@ -758,7 +758,7 @@ void plMipmap::ClipToMaxSize( UInt32 maxDimension ) #ifdef MEMORY_LEAK_TRACER IRemoveFromMemRecord( (UInt8 *)fImage ); #endif - delete [] fImage; + delete[] (UInt8*)fImage; plProfile_DelMem(MemMipmaps, fTotalSize); fImage = destData; @@ -789,7 +789,7 @@ void plMipmap::RemoveMipping() #ifdef MEMORY_LEAK_TRACER IRemoveFromMemRecord( (UInt8 *)fImage ); #endif - delete [] fImage; + delete[] (UInt8*)fImage; plProfile_DelMem(MemMipmaps, fTotalSize); fImage = destData; @@ -1556,7 +1556,7 @@ void plMipmap::CopyFrom( const plMipmap *source ) #ifdef MEMORY_LEAK_TRACER IRemoveFromMemRecord( (UInt8 *)fImage ); #endif - delete [] fImage; + delete[] (UInt8*)fImage; fWidth = source->fWidth; fHeight = source->fHeight; diff --git a/Sources/Plasma/PubUtilLib/plInterp/plAnimTimeConvert.cpp b/Sources/Plasma/PubUtilLib/plInterp/plAnimTimeConvert.cpp index 1a913720..9c0281ee 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plAnimTimeConvert.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plAnimTimeConvert.cpp @@ -397,7 +397,7 @@ void plAnimTimeConvert::IFlushOldStates() plATCStateList::const_iterator i = fStates.begin(); UInt32 count = 0; - for (i; i != fStates.end(); i++) + for (; i != fStates.end(); i++) { count++; state = *i; @@ -426,7 +426,7 @@ plATCState *plAnimTimeConvert::IGetState(double wSecs) const plATCState *state; plATCStateList::const_iterator i = fStates.begin(); - for (i; i != fStates.end(); i++) + for (; i != fStates.end(); i++) { state = *i; if (wSecs >= state->fStartWorldTime) @@ -589,7 +589,7 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs) // 2. Same as #1, but in the backwards case. // 3. We started before the wrap point, now we're after it. Stop. // 4. Same as #3, backwards. - if ((wrapped && (forewards && secs >= fWrapTime) || + if (((wrapped && (forewards && secs >= fWrapTime)) || (!forewards && secs <= fWrapTime)) || (forewards && fCurrentAnimTime < fWrapTime && secs >= fWrapTime) || (!forewards && fCurrentAnimTime > fWrapTime && secs <= fWrapTime)) @@ -700,7 +700,7 @@ hsScalar plAnimTimeConvert::IWorldToAnimTimeNoUpdate(double wSecs, plATCState *s if (state->fFlags & kWrap) { - if ((wrapped && (forewards && secs >= state->fWrapTime) || + if (((wrapped && (forewards && secs >= state->fWrapTime)) || (!forewards && secs <= state->fWrapTime)) || (forewards && state->fStartAnimTime < state->fWrapTime && secs >= state->fWrapTime) || (!forewards && state->fStartAnimTime > state->fWrapTime && secs <= state->fWrapTime)) diff --git a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp index 298e3708..2e9400cd 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp @@ -76,7 +76,7 @@ void plControllerCacheInfo::SetATC(plAnimTimeConvert *atc) plLeafController::~plLeafController() { - delete [] fKeys; + delete[] fKeys; } void plLeafController::Interp(hsScalar time, hsScalar* result, plControllerCacheInfo *cache) const diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp index 838a4574..b84c8df5 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp @@ -81,7 +81,7 @@ hsBool plParticleCollisionEffect::MsgReceive(plMessage* msg) plSceneObject *so; if (refMsg) { - if (so = plSceneObject::ConvertNoRef(refMsg->GetRef())) + if ((so = plSceneObject::ConvertNoRef(refMsg->GetRef()))) { if( refMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) ) fSceneObj = so; diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp index 243dc6e3..c07c9492 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp @@ -484,16 +484,16 @@ hsBool plParticleSystem::MsgReceive(plMessage* msg) plRenderMsg *rend; plAgeLoadedMsg* ageLoaded; - if (rend = plRenderMsg::ConvertNoRef(msg)) + if ((rend = plRenderMsg::ConvertNoRef(msg))) { plProfile_BeginLap(ParticleSys, this->GetKey()->GetUoid().GetObjectName()); IHandleRenderMsg(rend->Pipeline()); plProfile_EndLap(ParticleSys, this->GetKey()->GetUoid().GetObjectName()); return true; } - else if (refMsg = plGenRefMsg::ConvertNoRef(msg)) + else if ((refMsg = plGenRefMsg::ConvertNoRef(msg))) { - if (scene = plSceneObject::ConvertNoRef(refMsg->GetRef())) + if ((scene = plSceneObject::ConvertNoRef(refMsg->GetRef()))) { if (refMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace)) AddTarget(scene); @@ -501,7 +501,7 @@ hsBool plParticleSystem::MsgReceive(plMessage* msg) RemoveTarget(scene); return true; } - if (mat = hsGMaterial::ConvertNoRef(refMsg->GetRef())) + if ((mat = hsGMaterial::ConvertNoRef(refMsg->GetRef()))) { if (refMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace)) fTexture = mat; @@ -509,7 +509,7 @@ hsBool plParticleSystem::MsgReceive(plMessage* msg) fTexture = nil; return true; } - if (effect = plParticleEffect::ConvertNoRef(refMsg->GetRef())) + if ((effect = plParticleEffect::ConvertNoRef(refMsg->GetRef()))) { if (refMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace)) IAddEffect(effect, refMsg->fType); @@ -518,12 +518,12 @@ hsBool plParticleSystem::MsgReceive(plMessage* msg) return true; } } - else if (partMsg = plParticleUpdateMsg::ConvertNoRef(msg)) + else if ((partMsg = plParticleUpdateMsg::ConvertNoRef(msg))) { UpdateGenerator(partMsg->GetParamID(), partMsg->GetParamValue()); return true; } - else if (killMsg = plParticleKillMsg::ConvertNoRef(msg)) + else if ((killMsg = plParticleKillMsg::ConvertNoRef(msg))) { KillParticles(killMsg->fNumToKill, killMsg->fTimeLeft, killMsg->fFlags); return true; @@ -714,4 +714,4 @@ void plParticleSystem::SetAttachedToAvatar(bool attached) void plParticleSystem::AddLight(plKey liKey) { fPermaLights.Append(liKey); -} \ No newline at end of file +} diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plBSDiffBuffer.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plBSDiffBuffer.cpp index 6eeec14b..a3c89553 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plBSDiffBuffer.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plBSDiffBuffer.cpp @@ -297,7 +297,7 @@ void plBSDiffBuffer::GetBuffer( UInt32 &length, void *&bufferPtr ) if (fPatchBuffer && fPatchLength) { length = fPatchLength; - if (bufferPtr = (void *)TRACKED_NEW unsigned char[ length ]) + if ((bufferPtr = (void *)new unsigned char[ length ])) memcpy(bufferPtr, fPatchBuffer, length); } else @@ -432,7 +432,7 @@ UInt32 plBSDiffBuffer::Patch( UInt32 oldLength, void *oldBuffer, UInt32 &newLeng if(newpos != newend) { - delete[] newBuffer; + delete[] (unsigned char*)newBuffer; newLength = 0; } diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp index 7f7919ee..45476472 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp @@ -376,7 +376,7 @@ class plPageFinder : public plRegistryPageIterator } // Try for full location - sprintf( str, "%s_%s_%s", info.GetAge(), info.GetPage() ); + sprintf( str, "%s_%s", info.GetAge(), info.GetPage() ); if( stricmp( str, fFindString ) == 0 ) { *fPagePtr = node; diff --git a/Sources/Plasma/PubUtilLib/plSDL/plSDL.h b/Sources/Plasma/PubUtilLib/plSDL/plSDL.h index d93bc17f..4daeba0e 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plSDL.h +++ b/Sources/Plasma/PubUtilLib/plSDL/plSDL.h @@ -446,7 +446,7 @@ public: plSimpleStateVariable* FindVar(const char* name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); } plSDStateVariable* FindSDVar(const char* name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); } - plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); } + plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; } void CopyFrom(const plStateDataRecord& other, UInt32 writeOptions=0); void UpdateFrom(const plStateDataRecord& other, UInt32 writeOptions=0); void SetFromDefaults(bool timeStampNow); diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp index 2440534f..89b4485a 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp @@ -92,12 +92,12 @@ public: int fDataLen; plSDLCreatableStub(UInt16 classIndex, int len) : fClassIndex(classIndex),fData(nil),fDataLen(len) {} - ~plSDLCreatableStub() { delete [] fData; } + ~plSDLCreatableStub() { delete[] (char*)fData; } const char* ClassName() const { return "SDLCreatable"; } UInt16 ClassIndex() const { return fClassIndex; } - void Read(hsStream* s, hsResMgr* mgr) { delete [] fData; fData = TRACKED_NEW char[fDataLen]; s->Read(fDataLen, fData); } + void Read(hsStream* s, hsResMgr* mgr) { delete[] (char*)fData; fData = new char[fDataLen]; s->Read(fDataLen, fData); } void Write(hsStream* s, hsResMgr* mgr) { s->Write(fDataLen, fData); } }; @@ -112,7 +112,7 @@ void plStateVarNotificationInfo::Read(hsStream* s, UInt32 readOptions) if (hint && !(readOptions & plSDL::kSkipNotificationInfo)) fHintString = (const char*)hint; // we're done with it... - delete [] hint; + delete[] hint; } void plStateVarNotificationInfo::Write(hsStream* s, UInt32 writeOptions) const @@ -1874,6 +1874,8 @@ bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx, } } break; + default: + break; } return true; } @@ -2162,6 +2164,7 @@ void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other NOTIFY_CHECK(plVarDescriptor::kByte, fBy) NOTIFY_CHECK(plVarDescriptor::kFloat, fF) NOTIFY_CHECK(plVarDescriptor::kDouble, fD) + default: break; } } if (notify) diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp index 7740cabd..147777d1 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp @@ -826,12 +826,12 @@ bool plStatusLog::IPrintLineToFile( const char *line, UInt32 count ) } if (fFlags & kRawTimeStamp) { - snprintf(work, arrsize(work), "[t=%10u] ", hsTimer::GetSeconds()); + snprintf(work, arrsize(work), "[t=%10f] ", hsTimer::GetSeconds()); strncat(buf, work, arrsize(work)); } if (fFlags & kThreadID) { - snprintf(work, arrsize(work), "[t=%u] ", hsThread::GetMyThreadId()); + snprintf(work, arrsize(work), "[t=%lu] ", hsThread::GetMyThreadId()); strncat(buf, work, arrsize(work)); } diff --git a/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp b/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp index a56a132d..6882e336 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp @@ -583,7 +583,7 @@ hsBool plLayerLinkAnimation::MsgReceive( plMessage* pMsg ) if (msg->HasLinkFlag(plLinkEffectBCMsg::kSendCallback)) { plLinkEffectsMgr *mgr; - if (mgr = plLinkEffectsMgr::ConvertNoRef(msg->GetSender()->ObjectIsLoaded())) + if ((mgr = plLinkEffectsMgr::ConvertNoRef(msg->GetSender()->ObjectIsLoaded()))) mgr->WaitForEffect(msg->fLinkKey, fTimeConvert.GetEnd() - fTimeConvert.GetBegin()); } } @@ -603,7 +603,7 @@ hsBool plLayerLinkAnimation::MsgReceive( plMessage* pMsg ) // add a callback for when it's done if it's in forward plLinkEffectsMgr *mgr; - if (mgr = plLinkEffectsMgr::ConvertNoRef(pMsg->GetSender()->ObjectIsLoaded())) + if ((mgr = plLinkEffectsMgr::ConvertNoRef(pMsg->GetSender()->ObjectIsLoaded()))) if (pSeudoMsg->fForward) mgr->WaitForPseudoEffect(fLinkKey, fTimeConvert.GetEnd() - fTimeConvert.GetBegin()); diff --git a/Sources/Plasma/PubUtilLib/plTransform/mat_decomp.cpp b/Sources/Plasma/PubUtilLib/plTransform/mat_decomp.cpp index ebdd9e5c..385eceab 100644 --- a/Sources/Plasma/PubUtilLib/plTransform/mat_decomp.cpp +++ b/Sources/Plasma/PubUtilLib/plTransform/mat_decomp.cpp @@ -437,7 +437,7 @@ gemQuat snuggle(gemQuat q, HVect *k) mag[0] = (double)q.z*q.z+(double)q.w*q.w-0.5; mag[1] = (double)q.x*q.z-(double)q.y*q.w; mag[2] = (double)q.y*q.z+(double)q.x*q.w; - for (i=0; i<3; i++) if (neg[i] = (mag[i]<0.0)) mag[i] = -mag[i]; + for (i=0; i<3; i++) if ((neg[i] = (mag[i]<0.0))) mag[i] = -mag[i]; if (mag[0]>mag[1]) {if (mag[0]>mag[2]) win = 0; else win = 2;} else {if (mag[1]>mag[2]) win = 1; else win = 2;} switch (win) { @@ -456,7 +456,7 @@ gemQuat snuggle(gemQuat q, HVect *k) qa[0] = q.x; qa[1] = q.y; qa[2] = q.z; qa[3] = q.w; for (i=0; i<4; i++) { pa[i] = 0.0; - if (neg[i] = (qa[i]<0.0)) qa[i] = -qa[i]; + if ((neg[i] = (qa[i]<0.0))) qa[i] = -qa[i]; par ^= neg[i]; } /* Find two largest components, indices in hi and lo */