Merge pull request #225 from svost/msvc-C4244
authorCryptoManiac <CryptoManiac@users.noreply.github.com>
Mon, 18 May 2015 18:53:07 +0000 (21:53 +0300)
committerCryptoManiac <CryptoManiac@users.noreply.github.com>
Mon, 18 May 2015 18:53:07 +0000 (21:53 +0300)
Fix some msvc C4244 warnings (possible loss of data), also useless cast (ptime)

src/key.cpp
src/netbase.cpp
src/netbase.h
src/stun.cpp
src/util.cpp

index 540d44f..6239ba5 100644 (file)
@@ -411,8 +411,8 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
     int nBitsS = BN_num_bits(sig->s);
     if (nBitsR <= 256 && nBitsS <= 256)
     {
-        int nRecId = -1;
-        for (int i=0; i<4; i++)
+        int8_t nRecId = -1;
+        for (int8_t i=0; i<4; i++)
         {
             CKey keyRec;
             keyRec.fSet = true;
index 744a5b0..320db3e 100644 (file)
@@ -623,7 +623,7 @@ CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup)
         *this = vIP[0];
 }
 
-unsigned int CNetAddr::GetByte(int n) const
+uint8_t CNetAddr::GetByte(int n) const
 {
     return ip[15-n];
 }
@@ -851,7 +851,7 @@ bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const
 std::vector<unsigned char> CNetAddr::GetGroup() const
 {
     std::vector<unsigned char> vchRet;
-    int nClass = NET_IPV6;
+    uint8_t nClass = NET_IPV6;
     int nStartByte = 0;
     int nBits = 16;
 
index 01d8898..765609c 100644 (file)
@@ -66,7 +66,7 @@ class CNetAddr
         enum Network GetNetwork() const;
         std::string ToString() const;
         std::string ToStringIP() const;
-        unsigned int GetByte(int n) const;
+        uint8_t GetByte(int n) const;
         uint64_t GetHash() const;
         bool GetInAddr(struct in_addr* pipv4Addr) const;
         std::vector<unsigned char> GetGroup() const;
index 30da395..62e302f 100644 (file)
@@ -456,7 +456,7 @@ static int StunRequest2(int sock, struct sockaddr_in *server, struct sockaddr_in
 
     req = (struct stun_header *)reqdata;
     stun_req_id(req);
-    int reqlen = 0;
+    unsigned short reqlen = 0;
     req->msgtype = 0;
     req->msglen = 0;
     req->msglen = htons(reqlen);
index 43c8038..ed7b34d 100644 (file)
@@ -1155,7 +1155,7 @@ string randomStrGen(int length) {
 
 void createConf()
 {
-    srand(time(NULL));
+    srand(static_cast<unsigned int>(time(NULL)));
 
     ofstream pConf;
 #if BOOST_FILESYSTEM_VERSION >= 3