diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h index 0269e1a69..da5c33e6a 100644 --- a/code/nel/include/nel/gui/lua_helper.h +++ b/code/nel/include/nel/gui/lua_helper.h @@ -88,7 +88,7 @@ namespace NLGUI { public: ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); } - virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); } + virtual ~ELuaError() NL_OVERRIDE { CLuaStackChecker::decrementExceptionContextCounter(); } ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); } // what(), plus append the Reason virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} @@ -100,9 +100,9 @@ namespace NLGUI public: ELuaParseError() {} ELuaParseError(const std::string &reason) : ELuaError(reason) {} - virtual ~ELuaParseError() throw() { } + virtual ~ELuaParseError() NL_OVERRIDE { } // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());} + virtual std::string luaWhat() const throw() NL_OVERRIDE {return NLMISC::toString("ELuaParseError: %s", what());} }; /** Exception thrown when something went wrong inside a wrapped function called by lua @@ -113,8 +113,8 @@ namespace NLGUI ELuaWrappedFunctionException(CLuaState *luaState); ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason); ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...); - virtual ~ELuaWrappedFunctionException() throw() { } - virtual const char *what() const throw() {return _Reason.c_str();} + virtual ~ELuaWrappedFunctionException() NL_OVERRIDE { } + virtual const char *what() const throw() NL_OVERRIDE {return _Reason.c_str();} protected: void init(CLuaState *ls, const std::string &reason); protected: @@ -127,9 +127,9 @@ namespace NLGUI public: ELuaExecuteError() {} ELuaExecuteError(const std::string &reason) : ELuaError(reason) {} - virtual ~ELuaExecuteError() throw() { } + virtual ~ELuaExecuteError() NL_OVERRIDE { } // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} + virtual std::string luaWhat() const throw() NL_OVERRIDE {return NLMISC::toString("ELuaExecuteError: %s", what());} }; // A bad cast occurred when using lua_checkcast diff --git a/code/nel/src/georges/form.cpp b/code/nel/src/georges/form.cpp index 7fb51402e..c3fea6e0a 100644 --- a/code/nel/src/georges/form.cpp +++ b/code/nel/src/georges/form.cpp @@ -134,13 +134,13 @@ void CForm::write (xmlDocPtr doc, const std::string &filename) } // Write elements - Elements.write (node, this, NULL, true); + Elements.write (node, this, std::string(), true); // Write held elements uint i; for (i=0; iwrite (node, this, NULL, true); + HeldElements[i]->write (node, this, std::string(), true); } // Header @@ -273,7 +273,7 @@ void CForm::write (NLMISC::IStream &stream) xmlStream.init (&stream); // Write the file - write (xmlStream.getDocument (), NULL); + write (xmlStream.getDocument (), std::string()); } // *************************************************************************** diff --git a/code/nel/src/georges/type.cpp b/code/nel/src/georges/type.cpp index e8b2a8b5b..1055313dd 100644 --- a/code/nel/src/georges/type.cpp +++ b/code/nel/src/georges/type.cpp @@ -599,7 +599,7 @@ bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *nod else if (evaluate == UFormElm::Eval) { // Evaluate numerical expression - if ((Type == Double) || (Type == SignedInt) || (Type == UnsignedInt) || (Type == UnsignedInt)) + if ((Type == Double) || (Type == SignedInt) || (Type == UnsignedInt)) { // Evaluate predefinition uint i; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 8f1d104c9..dacaf16cf 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -1540,6 +1540,7 @@ namespace NLGUI for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) { CViewBase *pIE = *ite; + nlassert(pIE); if (pIE->getActive()) { const CInterfaceElement *el = pIE->getParentPos() ? pIE->getParentPos() : pIE->getParent(); diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index 966354e10..03a1212d3 100644 --- a/code/nel/src/gui/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -667,6 +667,7 @@ namespace NLGUI string elt = Target.substr(0,Target.rfind(':')); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); CInterfaceGroup *pIG = dynamic_cast(pIE); + nlassert(pIE); if (pIG == NULL) pIG = pIE->getParent(); diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 132f1e4b9..946baa560 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -741,7 +741,7 @@ namespace NLGUI } // because this is a method, first parameter is the 'this' CReflectableRefPtrTarget *pRPT = getReflectableOnStack(*state, 1); - if (pRPT == NULL) + if (!pRPT) { state->push(NLMISC::toString("Error while calling lua method %s:%s : 'self' pointer is nil or of bad type, can't make the call.", prop->ParentClass->ClassName.c_str(), prop->Name.c_str()) @@ -752,19 +752,22 @@ namespace NLGUI state->remove(1); // remove 'self' reference from parameters stack // sint numResults = 0; - sint initialStackSize = state->getTop(); - try + if (pRPT) { - // call the actual method - numResults = (pRPT->*(prop->GetMethod.GetLuaMethod))(*state); - } - catch(const std::exception &e) - { - // restore stack to its initial size - state->setTop(initialStackSize); - lua_pushstring(ls, e.what()); - // TODO : see if this is safe to call lua error there" ... (it does a long jump) - lua_error(ls); + sint initialStackSize = state->getTop(); + try + { + // call the actual method + numResults = (pRPT->*(prop->GetMethod.GetLuaMethod))(*state); + } + catch (const std::exception & e) + { + // restore stack to its initial size + state->setTop(initialStackSize); + lua_pushstring(ls, e.what()); + // TODO : see if this is safe to call lua error there" ... (it does a long jump) + lua_error(ls); + } } return numResults; } @@ -787,6 +790,7 @@ namespace NLGUI CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string script; ls.toString(2, script); + nlassert(pIE); // must be a group CInterfaceGroup *group= dynamic_cast(pIE); @@ -845,6 +849,7 @@ namespace NLGUI std::string dbList, script; ls.toString(2, dbList); ls.toString(3, script); + nlassert(pIE); // must be a group CInterfaceGroup *group= dynamic_cast(pIE); @@ -873,6 +878,7 @@ namespace NLGUI CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string dbList; ls.toString(2, dbList); + nlassert(pIE); // must be a group CInterfaceGroup *group= dynamic_cast(pIE); diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp index 4c2db062a..82716de4a 100644 --- a/code/nel/src/gui/view_renderer.cpp +++ b/code/nel/src/gui/view_renderer.cpp @@ -887,7 +887,7 @@ namespace NLGUI while (!iFile.eof()) { iFile.getline (bufTmp, 256); - sscanf (bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV); + sscanf (bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV); // FIXME: Return value ignored, tgaName may be uninitialized SImage image; image.UVMin.U = uvMinU; image.UVMin.V = uvMinV; diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index c0a6a4c85..864e4ef5b 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -2372,6 +2372,7 @@ namespace NLGUI // make sure all parent windows are active CCtrlBase *cb = getCaptureKeyboard(); CGroupContainer *lastContainer = NULL; + nlassert(cb); for(;;) { CGroupContainer *gc = dynamic_cast(cb); @@ -3226,6 +3227,7 @@ namespace NLGUI for( j = 0; j < mg.Group->getNumGroup(); j++ ) { CInterfaceGroup *g = mg.Group->getGroup( j ); + nlassert(g); if( dynamic_cast< CGroupModal* >( g ) != NULL ) continue; diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 13fe82247..015a9c4c4 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -2046,7 +2046,7 @@ void CBitmap::resamplePicture32 (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *pDest sint32 nDestWidth, sint32 nDestHeight) { //logResample("RP32: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight); - if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0)) + if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestWidth<=0)||(nDestHeight<=0)) return; // If we're reducing it by 2, call the fast resample @@ -2268,7 +2268,7 @@ void CBitmap::resamplePicture8 (const uint8 *pSrc, uint8 *pDest, sint32 nDestWidth, sint32 nDestHeight) { //logResample("RP8: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight); - if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0)) + if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestWidth<=0)||(nDestHeight<=0)) return; // If we're reducing it by 2, call the fast resample diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 3113de70e..cc3203a14 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -449,7 +449,7 @@ public: EDebug() { _Reason = "Nothing about EDebug"; } - virtual ~EDebug() throw() {} + virtual ~EDebug() NL_OVERRIDE {} EDebug(EXCEPTION_POINTERS * pexp) : m_pexp(pexp) { nlassert(pexp != 0); createWhat(); } EDebug(const EDebug& se) : m_pexp(se.m_pexp) { createWhat(); } @@ -863,9 +863,10 @@ public: cleanType (type, displayType); char tmp[1024]; + tmp[0]='\0'; if(type == "void") { - tmp[0]='\0'; + // tmp[0]='\0'; } else if(type == "int") { @@ -1716,6 +1717,7 @@ NLMISC_CATEGORISED_COMMAND(nel, writeaccess, "write a uint8 value in an invalid #endif } if(args.size() >= 2) NLMISC::fromString(args[1], val); + nlassume(adr); *adr = val; return true; } @@ -1736,6 +1738,7 @@ NLMISC_CATEGORISED_COMMAND(nel, readaccess, "read a uint8 value in an invalid ad adr = (uint8*)addr32; #endif } + nlassume(adr); val = *adr; log.displayNL("value is %hu", (uint16)val); return true; diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index 71d0fd4e2..9978b37e0 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -570,7 +570,7 @@ string CEntityIdTranslator::getUserName (uint32 uid) return entity.UserName; } } - return 0; + return string(); } void CEntityIdTranslator::getEntityIdInfo (const CEntityId &eid, ucstring &entityName, sint8 &entitySlot, uint32 &uid, string &userName, bool &online, std::string* additional) diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index ae5c8615e..87f848ab9 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -171,8 +171,7 @@ bool CIXml::init (IStream &stream) // Try binary mode if (_TryBinaryMode) { - string header; - header.resize(4); + char header[4]; header[0] = buffer[0]; header[1] = buffer[1]; header[2] = buffer[2]; @@ -180,7 +179,7 @@ bool CIXml::init (IStream &stream) toLower(header); // Does it a xml stream ? - if (header != "InternalSurface == currentSurfId); for (oedge=0; oedge<3 && next->Edge[oedge]!=currentFace; ++oedge) diff --git a/code/ryzom/common/src/game_share/crypt.cpp b/code/ryzom/common/src/game_share/crypt.cpp index a10c2ab6e..1416cac52 100644 --- a/code/ryzom/common/src/game_share/crypt.cpp +++ b/code/ryzom/common/src/game_share/crypt.cpp @@ -533,7 +533,7 @@ std::string rz_crypt(register const char *key, register const char *setting, cha keyblock.b[i] = t; } if (rz_des_setkey((char *)keyblock.b)) /* also initializes "a64toi" */ - return (NULL); + return std::string(); encp = &cryptresult[0]; switch (*setting) { @@ -544,14 +544,14 @@ std::string rz_crypt(register const char *key, register const char *setting, cha while (*key) { if (rz_des_cipher((char *)&keyblock, (char *)&keyblock, 0L, 1)) - return (NULL); + return std::string(); for (i = 0; i < 8; i++) { if ((t = 2*(unsigned char)(*key)) != 0) key++; keyblock.b[i] ^= t; } if (rz_des_setkey((char *)keyblock.b)) - return (NULL); + return std::string(); } *encp++ = *setting++; @@ -583,7 +583,7 @@ std::string rz_crypt(register const char *key, register const char *setting, cha encp += salt_size; if (rz_des_cipher((char *)&constdatablock, (char *)&rsltblock, salt, num_iter)) - return ""; + return std::string(); /* * Encode the 64 cipher bits as 11 ascii characters. diff --git a/code/ryzom/common/src/game_share/mirrored_data_set.cpp b/code/ryzom/common/src/game_share/mirrored_data_set.cpp index 2d854c47a..8db024784 100644 --- a/code/ryzom/common/src/game_share/mirrored_data_set.cpp +++ b/code/ryzom/common/src/game_share/mirrored_data_set.cpp @@ -1763,6 +1763,7 @@ void CMirroredDataSet::getValueToString( const TDataSetRow& entityIndex, TPro } default: result = toString( " (%s/E%d/P%hd)", name().c_str(), entityIndex.getIndex(), propIndex ); + return; } result = string(tmpStr); } diff --git a/code/ryzom/common/src/game_share/object.cpp b/code/ryzom/common/src/game_share/object.cpp index c9315997f..ef567d31a 100644 --- a/code/ryzom/common/src/game_share/object.cpp +++ b/code/ryzom/common/src/game_share/object.cpp @@ -1480,7 +1480,7 @@ bool CObjectTable::canTake(sint32 position) const { CObject* parent = getParent(); - if (parent) //try to take the root of a tree + if (!parent) //try to take the root of a tree { return true; } diff --git a/code/ryzom/common/src/game_share/server_animation_module.cpp b/code/ryzom/common/src/game_share/server_animation_module.cpp index 0f0c90bb0..3c3276130 100644 --- a/code/ryzom/common/src/game_share/server_animation_module.cpp +++ b/code/ryzom/common/src/game_share/server_animation_module.cpp @@ -667,11 +667,12 @@ void CAttributeToProperty::setAiStateName(const std::string& prefix) std::string name; CObject* tmp=_Object->getAttr("Id"); - if( !(tmp&&tmp->isString())&&((name = tmp->toString()).length()!=0)) + if (!tmp || !tmp->isString()) { nlwarning("R2Ani: invalide rtData"); return; } + name = tmp->toString(); _Primitive->addPropertyByName("name", new CPropertyString(prefix + name)); diff --git a/code/ryzom/common/src/game_share/utils.h b/code/ryzom/common/src/game_share/utils.h index ed71af34b..a534b156b 100644 --- a/code/ryzom/common/src/game_share/utils.h +++ b/code/ryzom/common/src/game_share/utils.h @@ -122,8 +122,8 @@ inline ucstring capitalize(const ucstring & s) #define GIVEUP_IF(condition,msg,action) if (!(condition));else GIVEUP(msg,action) #define WARN_IF(condition,msg) if (!(condition));else WARN(msg) #define DROP_IF(condition,msg,action) if (!(condition));else DROP(msg,action) -#define BOMB_IF(condition,msg,action) if (!(condition));else BOMB(msg,action) -#define STOP_IF(condition,msg) if (!(condition));else STOP(msg) +#define BOMB_IF(condition,msg,action) if (!(condition));else BOMB(msg,action); do { nlassume(condition); } while (0) +#define STOP_IF(condition,msg) if (!(condition));else STOP(msg); do { nlassume(condition); } while (0) // testing for variable value changes #define ON_CHANGE(type,var,code)\