From 51b6cf6bfaf33478ab975284450266d31e20b312 Mon Sep 17 00:00:00 2001 From: paulc Date: Tue, 9 Feb 2021 14:08:19 +0000 Subject: [PATCH] Fixed several issues exposed by the Microsoft compiler. git-svn-id: http://yate.null.ro/svn/yate/trunk@6459 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/String.cpp | 2 +- libs/yrtp/session.cpp | 2 +- libs/yscript/evaluator.cpp | 4 ++++ libs/yscript/javascript.cpp | 4 +++- libs/yscript/jsobjects.cpp | 2 +- libs/ysdp/media.cpp | 2 +- modules/ysipchan.cpp | 6 +++--- windows/libyscript.vcproj | 4 ++-- 8 files changed, 16 insertions(+), 10 deletions(-) diff --git a/engine/String.cpp b/engine/String.cpp index 769b152f..88e82f4f 100644 --- a/engine/String.cpp +++ b/engine/String.cpp @@ -327,7 +327,7 @@ bool UChar::decode(DataBlock& buff, Endianness order, uint32_t maxChar) len = len >> 1; if (!decode(in,len,order,maxChar)) return false; - buff.cut(-(buff.length() - len * 2)); + buff.cut(-(int)(buff.length() - len * 2)); return true; } diff --git a/libs/yrtp/session.cpp b/libs/yrtp/session.cpp index 6e78dcf5..685de7ac 100644 --- a/libs/yrtp/session.cpp +++ b/libs/yrtp/session.cpp @@ -638,7 +638,7 @@ bool RTPSender::sendEventData(unsigned int timestamp) if (m_debugEvent) TraceDebug(m_traceId,dbg(),m_debugDataLevel, "RTP send event=%d ts=%u event_ts=%u duration=%u ev_duration=%u ev_seq=%u end=%s [%p]", - m_evNum,timestamp,m_evTs,duration,m_evTime,m_evSeq,String::boolText(end),this); + m_evNum,timestamp,m_evTs,duration,m_evTime,m_evSeq,String::boolText(0 != end),this); if (end) duration = m_evTime; char buf[4]; diff --git a/libs/yscript/evaluator.cpp b/libs/yscript/evaluator.cpp index dba30b58..12c7caf3 100644 --- a/libs/yscript/evaluator.cpp +++ b/libs/yscript/evaluator.cpp @@ -388,7 +388,11 @@ bool ExpEvaluator::getNumber(ParsePoint& expr) #undef DLONG_MAX expr += str.length(); ExpOperation* op = addOpcode(str); +#ifdef _WINDOWS + op->m_number = (int64_t)((val >= 0) ? (val + 0.5) : (val - 0.5)); +#else op->m_number = ::round(val); +#endif op->m_isNumber = true; DDebug(this,DebugAll,"Fake float %s ~ " FMT64,str.safe(),op->m_number); return true; diff --git a/libs/yscript/javascript.cpp b/libs/yscript/javascript.cpp index 287b33d9..e87c630d 100644 --- a/libs/yscript/javascript.cpp +++ b/libs/yscript/javascript.cpp @@ -3438,9 +3438,11 @@ unsigned int JsRunner::currentLineNo() const const String& JsRunner::currentFileName(bool wholePath) const { + static const String s_unk("???"); + const ExpOperation* o = getCurrentOpCode(); if (!(o && code())) - return YSTRING("???"); + return s_unk; return (static_cast(code()))->getFileName(o->lineNumber(),wholePath); } diff --git a/libs/yscript/jsobjects.cpp b/libs/yscript/jsobjects.cpp index 82c740ba..1b439e56 100644 --- a/libs/yscript/jsobjects.cpp +++ b/libs/yscript/jsobjects.cpp @@ -194,7 +194,7 @@ static void dumpRecursiveObj(const GenObject* obj, String& buf, unsigned int dep if (depth && !isProto && ((isFunc && (0 == (flags & JsObject::DumpFunc))) || (!isFunc && (0 == (flags & JsObject::DumpProp))))) return; - bool dumpType = flags & JsObject::DumpType; + bool dumpType = 0 != (flags & JsObject::DumpType); if (nstr) { str << "'" << nstr->name() << "'"; // Nicely dump property value if dumping props only and type is not shown diff --git a/libs/ysdp/media.cpp b/libs/ysdp/media.cpp index 043bf645..3ab78e88 100644 --- a/libs/ysdp/media.cpp +++ b/libs/ysdp/media.cpp @@ -84,7 +84,7 @@ bool SDPMedia::sameAs(const SDPMedia* other, bool ignorePort, bool checkStarted) // Check format ObjList* lst = m.formats().split(',',false); - bool found = lst->find(m_format); + bool found = (0 != lst->find(m_format)); TelEngine::destruct(lst); if (!found) { XDebug(DebugAll,"SDPMedia::sameAs(%p) format='%s' other_formats='%s': not found [%p]", diff --git a/modules/ysipchan.cpp b/modules/ysipchan.cpp index 7d5c123b..52be33b4 100644 --- a/modules/ysipchan.cpp +++ b/modules/ysipchan.cpp @@ -6385,7 +6385,7 @@ YateSIPConnection::YateSIPConnection(Message& msg, const String& uri, const char m_uri = tmp; m_uri.parse(); sips(m_uri.getProtocol() == YSTRING("sips")); - if (!setParty(msg,false,"o",m_uri.getHost(),m_uri.getPort(),this) && line) { + if (!setParty(msg,false,"o",m_uri.getHost(),m_uri.getPort(),true) && line) { SIPParty* party = line->party(); setParty(party); TelEngine::destruct(party); @@ -6393,7 +6393,7 @@ YateSIPConnection::YateSIPConnection(Message& msg, const String& uri, const char // No party for SIPS and we don't have transport related params // Force party creation: this will force used protocol to TLS if (!m_party && sips() && !haveTransParams(msg,"o")) - setParty(msg,true,"o",m_uri.getHost(),m_uri.getPort(),this); + setParty(msg,true,"o",m_uri.getHost(),m_uri.getPort(),true); SIPMessage* m = new SIPMessage("INVITE",m_uri); m->dontSend(m_stopOCall); m->msgTraceId = m_traceId; @@ -8195,7 +8195,7 @@ bool YateSIPConnection::callPrerouted(Message& msg, bool handled) bool ok = Channel::callPrerouted(msg,handled); m_autoChangeParty = msg.getBoolValue(YSTRING("iautochangeparty"),m_autoChangeParty); if (msg.getBoolValue(YSTRING("ioutbound_party"))) - ok = setParty(msg,true,"i",String::empty(),0,this) && ok; + ok = setParty(msg,true,"i",String::empty(),0,true) && ok; return ok; } diff --git a/windows/libyscript.vcproj b/windows/libyscript.vcproj index f712ccad..7854359f 100644 --- a/windows/libyscript.vcproj +++ b/windows/libyscript.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=".,..,..\libs\yscript,..\libs\yasn" - PreprocessorDefinitions="_DEBUG;WIN32;_LIB;LIBYSCRIPT_EXPORTS;LIBYASN_EXPORTS" + PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CRT_SECURE_NO_DEPRECATE;LIBYSCRIPT_EXPORTS;LIBYASN_EXPORTS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -130,7 +130,7 @@ Optimization="2" InlineFunctionExpansion="1" AdditionalIncludeDirectories=".,..,..\libs\yscript,..\libs\yasn" - PreprocessorDefinitions="NDEBUG;WIN32;_LIB;LIBYSCRIPT_EXPORTS;LIBYASN_EXPORTS" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CRT_SECURE_NO_DEPRECATE;LIBYSCRIPT_EXPORTS;LIBYASN_EXPORTS" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true"