From 9c51ce9c40c1eadd20e943f74f0694a0a6a05ae1 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 17 Jun 2019 13:32:41 -0700 Subject: Windows build fixes, fix double/float types to get rid of warnings. --- node/Path.hpp | 8 ++++---- node/Peer.cpp | 14 +++++++------- osdep/Binder.hpp | 2 +- windows/ZeroTierOne/ZeroTierOne.vcxproj | 4 ++++ windows/ZeroTierOne/ZeroTierOne.vcxproj.filters | 12 ++++++++++++ 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/node/Path.hpp b/node/Path.hpp index 5b966f6b..9203eee3 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -440,7 +440,7 @@ public: uint64_t id = it->first; memcpy(qosBuffer, &id, sizeof(uint64_t)); qosBuffer+=sizeof(uint64_t); - uint16_t holdingTime = (now - it->second); + uint16_t holdingTime = (uint16_t)(now - it->second); memcpy(qosBuffer, &holdingTime, sizeof(uint16_t)); qosBuffer+=sizeof(uint16_t); len+=sizeof(uint64_t)+sizeof(uint16_t); @@ -592,11 +592,11 @@ public: float throughput_cv = _throughputSamples.mean() > 0 ? _throughputSamples.stddev() / _throughputSamples.mean() : 1; // Form an exponential cutoff and apply contribution weights - float pdv_contrib = exp((-1)*normalized_pdv) * ZT_PATH_CONTRIB_PDV; - float latency_contrib = exp((-1)*normalized_la) * ZT_PATH_CONTRIB_LATENCY; + float pdv_contrib = expf((-1.0f)*normalized_pdv) * (float)ZT_PATH_CONTRIB_PDV; + float latency_contrib = expf((-1.0f)*normalized_la) * (float)ZT_PATH_CONTRIB_LATENCY; // Throughput Disturbance Coefficient - float throughput_disturbance_contrib = exp((-1)*throughput_cv) * ZT_PATH_CONTRIB_THROUGHPUT_DISTURBANCE; + float throughput_disturbance_contrib = expf((-1.0f)*throughput_cv) * (float)ZT_PATH_CONTRIB_THROUGHPUT_DISTURBANCE; _throughputDisturbanceSamples.push(throughput_cv); _lastComputedThroughputDistCoeff = _throughputDisturbanceSamples.mean(); diff --git a/node/Peer.cpp b/node/Peer.cpp index 029e45e7..a053ee48 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -300,13 +300,13 @@ void Peer::computeAggregateProportionalAllocation(int64_t now) float age_contrib = exp((-1)*normalized_ma); float relScope = ((float)(_paths[i].p->ipScope()+1) / (maxScope + 1)); float relQuality = - (relStability[i] * ZT_PATH_CONTRIB_STABILITY) - + (fmax(1, relThroughput[i]) * ZT_PATH_CONTRIB_THROUGHPUT) - + relScope * ZT_PATH_CONTRIB_SCOPE; + (relStability[i] * (float)ZT_PATH_CONTRIB_STABILITY) + + (fmaxf(1.0f, relThroughput[i]) * (float)ZT_PATH_CONTRIB_THROUGHPUT) + + relScope * (float)ZT_PATH_CONTRIB_SCOPE; relQuality *= age_contrib; // Arbitrary cutoffs - relQuality = relQuality > (1.00 / 100.0) ? relQuality : 0.0; - relQuality = relQuality < (99.0 / 100.0) ? relQuality : 1.0; + relQuality = relQuality > (1.00f / 100.0f) ? relQuality : 0.0f; + relQuality = relQuality < (99.0f / 100.0f) ? relQuality : 1.0f; totalRelativeQuality += relQuality; _paths[i].p->updateRelativeQuality(relQuality); } @@ -479,8 +479,8 @@ char *Peer::interfaceListStr() if (_paths[i].p && _paths[i].p->alive(now)) { int ipv = _paths[i].p->address().isV4(); // If this is acting as an aggregate link, check allocations - float targetAllocation = 1.0 / alivePathCount; - float currentAllocation = 1.0; + float targetAllocation = 1.0f / (float)alivePathCount; + float currentAllocation = 1.0f; if (alivePathCount > 1) { currentAllocation = (float)_pathChoiceHist.countValue(i) / (float)_pathChoiceHist.count(); if (fabs(targetAllocation - currentAllocation) > ZT_PATH_IMBALANCE_THRESHOLD) { diff --git a/osdep/Binder.hpp b/osdep/Binder.hpp index 10ffbb06..bf7aef28 100644 --- a/osdep/Binder.hpp +++ b/osdep/Binder.hpp @@ -389,7 +389,7 @@ public: _bindings[_bindingCount].udpSock = udps; _bindings[_bindingCount].tcpListenSock = tcps; _bindings[_bindingCount].address = ii->first; - phy.setIfName(udps, (char*)ii->second.c_str(), ii->second.length()); + phy.setIfName(udps,(char*)ii->second.c_str(),(int)ii->second.length()); ++_bindingCount; } } else { diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj index 60c87d3b..3f6397ca 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj @@ -30,6 +30,8 @@ + + @@ -114,6 +116,8 @@ + + diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters index f7df2034..1fcf7b69 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters @@ -258,6 +258,12 @@ Source Files\controller + + Source Files\controller + + + Source Files\controller + @@ -494,6 +500,12 @@ Header Files\node + + Header Files\controller + + + Header Files\controller + -- cgit v1.2.3