From 463a1cab43fda24f89f71fffc876756dc1bc155a Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Wed, 5 Sep 2012 23:36:19 +0200 Subject: [PATCH] fix signed/unsigned in strprintf and CNetAddr::GetByte() - I checked every occurance of strprintf() in the code and used %u, where unsigned vars are used - the change to GetByte() was made, as ip is an unsigned char --- src/bitcoinrpc.cpp | 2 +- src/main.h | 8 ++++---- src/net.cpp | 2 +- src/netbase.cpp | 4 ++-- src/netbase.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index fa392363..64154bf1 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -816,7 +816,7 @@ void ThreadRPCServer2(void* parg) } catch(boost::system::system_error &e) { - strerr = strprintf(_("An error occurred while setting up the RPC port %i for listening on IPv4: %s"), endpoint.port(), e.what()); + strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv4: %s"), endpoint.port(), e.what()); } if (!fListening) { diff --git a/src/main.h b/src/main.h index e61cbdd4..a233f00f 100644 --- a/src/main.h +++ b/src/main.h @@ -158,7 +158,7 @@ public: if (IsNull()) return "null"; else - return strprintf("(nFile=%d, nBlockPos=%d, nTxPos=%d)", nFile, nBlockPos, nTxPos); + return strprintf("(nFile=%u, nBlockPos=%u, nTxPos=%u)", nFile, nBlockPos, nTxPos); } void print() const @@ -214,7 +214,7 @@ public: std::string ToString() const { - return strprintf("COutPoint(%s, %d)", hash.ToString().substr(0,10).c_str(), n); + return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10).c_str(), n); } void print() const @@ -632,7 +632,7 @@ public: std::string ToString() const { std::string str; - str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%d, vout.size=%d, nLockTime=%d)\n", + str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n", GetHash().ToString().substr(0,10).c_str(), nVersion, vin.size(), @@ -1174,7 +1174,7 @@ public: std::string ToString() const { - return strprintf("CBlockIndex(pprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, merkle=%s, hashBlock=%s)", + return strprintf("CBlockIndex(pprev=%08x, pnext=%08x, nFile=%u, nBlockPos=%-6u nHeight=%d, merkle=%s, hashBlock=%s)", pprev, pnext, nFile, nBlockPos, nHeight, hashMerkleRoot.ToString().substr(0,10).c_str(), GetBlockHash().ToString().substr(0,20).c_str()); diff --git a/src/net.cpp b/src/net.cpp index c0693306..651f4a97 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1025,7 +1025,7 @@ void ThreadMapPort2(void* parg) { printf("ThreadMapPort started\n"); - std::string port = strprintf("%d", GetListenPort()); + std::string port = strprintf("%u", GetListenPort()); const char * multicastif = 0; const char * minissdpdpath = 0; struct UPNPDev * devlist = 0; diff --git a/src/netbase.cpp b/src/netbase.cpp index b66c3666..4face7a1 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -599,7 +599,7 @@ CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup) *this = vIP[0]; } -int CNetAddr::GetByte(int n) const +unsigned int CNetAddr::GetByte(int n) const { return ip[15-n]; } @@ -1135,7 +1135,7 @@ std::vector CService::GetKey() const std::string CService::ToStringPort() const { - return strprintf("%i", port); + return strprintf("%u", port); } std::string CService::ToStringIPPort() const diff --git a/src/netbase.h b/src/netbase.h index 07ca12cb..560e2182 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -66,7 +66,7 @@ class CNetAddr enum Network GetNetwork() const; std::string ToString() const; std::string ToStringIP() const; - int GetByte(int n) const; + unsigned int GetByte(int n) const; uint64 GetHash() const; bool GetInAddr(struct in_addr* pipv4Addr) const; std::vector GetGroup() const;