Merge pull request #203 from svost/C4245
authorCryptoManiac <CryptoManiac@users.noreply.github.com>
Tue, 14 Apr 2015 20:33:13 +0000 (23:33 +0300)
committerCryptoManiac <CryptoManiac@users.noreply.github.com>
Tue, 14 Apr 2015 20:33:13 +0000 (23:33 +0300)
Remove msvc C4245 warning, better readability.

src/main.cpp
src/net.cpp
src/net.h
src/protocol.cpp

index 28bdb47..21eef1e 100644 (file)
@@ -2387,7 +2387,7 @@ bool CBlock::AcceptBlock()
     // Write block to history file
     if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION)))
         return error("AcceptBlock() : out of disk space");
-    unsigned int nFile = -1;
+    unsigned int nFile = UINT_MAX;
     unsigned int nBlockPos = 0;
     if (!WriteToDisk(nFile, nBlockPos))
         return error("AcceptBlock() : WriteToDisk failed");
index 0b80e0d..90824d0 100644 (file)
@@ -308,7 +308,7 @@ extern int GetExternalIPbySTUN(uint64_t rnd, struct sockaddr_in *mapped, const c
 bool GetMyExternalIP(CNetAddr& ipRet)
 {
     struct sockaddr_in mapped;
-    uint64_t rnd = GetRand(~0LL);
+    uint64_t rnd = ULLONG_MAX;
     const char *srv;
     int rc = GetExternalIPbySTUN(rnd, &mapped, &srv);
     if(rc >= 0) {
index a946210..7306d13 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -233,7 +233,7 @@ public:
         nLastSendEmpty = GetTime();
         nTimeConnected = GetTime();
         nHeaderStart = -1;
-        nMessageStart = -1;
+        nMessageStart = UINT_MAX;
         addr = addrIn;
         addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
         nVersion = 0;
@@ -375,7 +375,7 @@ public:
             return;
         vSend.resize(nHeaderStart);
         nHeaderStart = -1;
-        nMessageStart = -1;
+        nMessageStart = UINT_MAX;
         LEAVE_CRITICAL_SECTION(cs_vSend);
 
         if (fDebug)
@@ -410,7 +410,7 @@ public:
         }
 
         nHeaderStart = -1;
-        nMessageStart = -1;
+        nMessageStart = UINT_MAX;
         LEAVE_CRITICAL_SECTION(cs_vSend);
     }
 
index 1bb578c..fc112a5 100644 (file)
@@ -23,7 +23,7 @@ CMessageHeader::CMessageHeader()
     memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
     memset(pchCommand, 0, sizeof(pchCommand));
     pchCommand[1] = 1;
-    nMessageSize = -1;
+    nMessageSize = UINT_MAX;
     nChecksum = 0;
 }