From 24de922636e664ac5f6a2189055e4c0b76dac0b7 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 1 May 2012 17:49:17 -0400 Subject: [PATCH 1/4] CDiskTxPos, CInPoint, COutPoint: cast null value (-1) to unsigned int to eliminate signed/unsigned comparison warnings --- src/main.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.h b/src/main.h index 262e77e806..caaf4f8499 100644 --- a/src/main.h +++ b/src/main.h @@ -136,8 +136,8 @@ public: } IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) - void SetNull() { nFile = -1; nBlockPos = 0; nTxPos = 0; } - bool IsNull() const { return (nFile == -1); } + void SetNull() { nFile = (unsigned int) -1; nBlockPos = 0; nTxPos = 0; } + bool IsNull() const { return (nFile == (unsigned int) -1); } friend bool operator==(const CDiskTxPos& a, const CDiskTxPos& b) { @@ -176,8 +176,8 @@ public: CInPoint() { SetNull(); } CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; } - void SetNull() { ptx = NULL; n = -1; } - bool IsNull() const { return (ptx == NULL && n == -1); } + void SetNull() { ptx = NULL; n = (unsigned int) -1; } + bool IsNull() const { return (ptx == NULL && n == (unsigned int) -1); } }; @@ -192,8 +192,8 @@ public: COutPoint() { SetNull(); } COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; } IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) - void SetNull() { hash = 0; n = -1; } - bool IsNull() const { return (hash == 0 && n == -1); } + void SetNull() { hash = 0; n = (unsigned int) -1; } + bool IsNull() const { return (hash == 0 && n == (unsigned int) -1); } friend bool operator<(const COutPoint& a, const COutPoint& b) { From 10ab9c2f4279e182f61a86a65f3a9b9cdba1df83 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 1 May 2012 17:50:33 -0400 Subject: [PATCH 2/4] OpenBlockFile(): cast to eliminate signed/unsigned comparison warning nFile's null value is -1. Cast that to unsigned int, to avoid warning. Additionally, avoid nFile==0 because the first valid value is 1. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 427e435a90..78427e0d3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1836,7 +1836,7 @@ bool CheckDiskSpace(uint64 nAdditionalBytes) FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode) { - if (nFile == -1) + if ((nFile < 1) || (nFile == (unsigned int) -1)) return NULL; FILE* file = fopen((GetDataDir() / strprintf("blk%04d.dat", nFile)).string().c_str(), pszMode); if (!file) From 061a00159099cd4236e9bc70d09731c8cb89afd9 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 1 May 2012 17:54:52 -0400 Subject: [PATCH 3/4] ThreadSocketHandler2(): cast to avoid signed/unsigned warning --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index d218dcfb5d..5d1a157050 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -621,7 +621,7 @@ void ThreadSocketHandler2(void* parg) if (nSelect == SOCKET_ERROR) { int nErr = WSAGetLastError(); - if (hSocketMax > -1) + if (hSocketMax > (SOCKET) -1) { printf("socket select error %d\n", nErr); for (unsigned int i = 0; i <= hSocketMax; i++) From 024fa1cb44b8ec577fef07e7b37a4e5b0501dbea Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 1 May 2012 17:57:12 -0400 Subject: [PATCH 4/4] EvalScript(): cast to avoid signed/unsigned warning --- src/script.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script.cpp b/src/script.cpp index 65e9b7c9a2..0b103a80bc 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -940,7 +940,7 @@ bool EvalScript(vector >& stack, const CScript& script, co // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) int i = 1; - if (stack.size() < i) + if ((int)stack.size() < i) return false; int nKeysCount = CastToBigNum(stacktop(-i)).getint(); @@ -951,7 +951,7 @@ bool EvalScript(vector >& stack, const CScript& script, co return false; int ikey = ++i; i += nKeysCount; - if (stack.size() < i) + if ((int)stack.size() < i) return false; int nSigsCount = CastToBigNum(stacktop(-i)).getint(); @@ -959,7 +959,7 @@ bool EvalScript(vector >& stack, const CScript& script, co return false; int isig = ++i; i += nSigsCount; - if (stack.size() < i) + if ((int)stack.size() < i) return false; // Subset of script starting at the most recent codeseparator