Merge pull request #399 from muggenhor/warning-fixes

Warning fixes
This commit is contained in:
Jeff Garzik 2011-07-12 20:22:38 -07:00
commit 4ea952d5c0
11 changed files with 18 additions and 20 deletions

View File

@ -80,7 +80,7 @@ bool CpuId(word32 input, word32 *output)
#endif #endif
} }
#ifndef _MSC_VER #if !CRYPTOPP_BOOL_X64 && !defined(_MSC_VER) && defined(__GNUC__)
static jmp_buf s_jmpNoSSE2; static jmp_buf s_jmpNoSSE2;
static void SigIllHandlerSSE2(int) static void SigIllHandlerSSE2(int)
{ {

View File

@ -627,8 +627,6 @@ int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries) void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries)
{ {
int64 nCreditDebit = 0;
bool fAllAccounts = (strAccount == "*"); bool fAllAccounts = (strAccount == "*");
Dbc* pcursor = GetCursor(); Dbc* pcursor = GetCursor();

View File

@ -88,7 +88,7 @@ protected:
if (!pdb) if (!pdb)
return false; return false;
if (fReadOnly) if (fReadOnly)
assert(("Write called on database in read-only mode", false)); assert(!"Write called on database in read-only mode");
// Key // Key
CDataStream ssKey(SER_DISK); CDataStream ssKey(SER_DISK);
@ -117,7 +117,7 @@ protected:
if (!pdb) if (!pdb)
return false; return false;
if (fReadOnly) if (fReadOnly)
assert(("Erase called on database in read-only mode", false)); assert(!"Erase called on database in read-only mode");
// Key // Key
CDataStream ssKey(SER_DISK); CDataStream ssKey(SER_DISK);

View File

@ -1688,7 +1688,7 @@ string GetWarnings(string strFor)
return strStatusBar; return strStatusBar;
else if (strFor == "rpc") else if (strFor == "rpc")
return strRPC; return strRPC;
assert(("GetWarnings() : invalid parameter", false)); assert(!"GetWarnings() : invalid parameter");
return "error"; return "error";
} }

View File

@ -831,7 +831,7 @@ void ThreadSocketHandler2(void* parg)
{ {
BOOST_FOREACH(CNode* pnode, vNodes) BOOST_FOREACH(CNode* pnode, vNodes)
{ {
if (pnode->hSocket == INVALID_SOCKET || pnode->hSocket < 0) if (pnode->hSocket == INVALID_SOCKET)
continue; continue;
FD_SET(pnode->hSocket, &fdsetRecv); FD_SET(pnode->hSocket, &fdsetRecv);
FD_SET(pnode->hSocket, &fdsetError); FD_SET(pnode->hSocket, &fdsetError);
@ -1700,7 +1700,7 @@ void StartNode(void* parg)
printf("Error: CreateThread(ThreadIRCSeed) failed\n"); printf("Error: CreateThread(ThreadIRCSeed) failed\n");
// Send and receive from sockets, accept connections // Send and receive from sockets, accept connections
pthread_t hThreadSocketHandler = CreateThread(ThreadSocketHandler, NULL, true); CreateThread(ThreadSocketHandler, NULL, true);
// Initiate outbound connections // Initiate outbound connections
if (!CreateThread(ThreadOpenConnections, NULL)) if (!CreateThread(ThreadOpenConnections, NULL))

View File

@ -706,7 +706,7 @@ int64 GetAccountBalance(const string& strAccount, int nMinDepth)
Value getbalance(const Array& params, bool fHelp) Value getbalance(const Array& params, bool fHelp)
{ {
if (fHelp || params.size() < 0 || params.size() > 2) if (fHelp || params.size() > 2)
throw runtime_error( throw runtime_error(
"getbalance [account] [minconf=1]\n" "getbalance [account] [minconf=1]\n"
"If [account] is not specified, returns the server's total available balance.\n" "If [account] is not specified, returns the server's total available balance.\n"
@ -2419,7 +2419,6 @@ int CommandLineRPC(int argc, char *argv[])
// Parse reply // Parse reply
const Value& result = find_value(reply, "result"); const Value& result = find_value(reply, "result");
const Value& error = find_value(reply, "error"); const Value& error = find_value(reply, "error");
const Value& id = find_value(reply, "id");
if (error.type() != null_type) if (error.type() != null_type)
{ {

View File

@ -580,6 +580,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
case OP_ABS: if (bn < bnZero) bn = -bn; break; case OP_ABS: if (bn < bnZero) bn = -bn; break;
case OP_NOT: bn = (bn == bnZero); break; case OP_NOT: bn = (bn == bnZero); break;
case OP_0NOTEQUAL: bn = (bn != bnZero); break; case OP_0NOTEQUAL: bn = (bn != bnZero); break;
default: assert(!"invalid opcode"); break;
} }
popstack(stack); popstack(stack);
stack.push_back(bn.getvch()); stack.push_back(bn.getvch());
@ -659,6 +660,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break;
case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break; case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break;
case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break; case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break;
default: assert(!"invalid opcode"); break;
} }
popstack(stack); popstack(stack);
popstack(stack); popstack(stack);

View File

@ -486,7 +486,7 @@ public:
{ {
// I'm not sure if this should push the script or concatenate scripts. // I'm not sure if this should push the script or concatenate scripts.
// If there's ever a use for pushing a script onto a script, delete this member fn // If there's ever a use for pushing a script onto a script, delete this member fn
assert(("warning: pushing a CScript onto a CScript with << is probably not intended, use + to concatenate", false)); assert(!"warning: pushing a CScript onto a CScript with << is probably not intended, use + to concatenate");
return *this; return *this;
} }

View File

@ -760,8 +760,8 @@ string GetPidFile()
void CreatePidFile(string pidFile, pid_t pid) void CreatePidFile(string pidFile, pid_t pid)
{ {
FILE* file; FILE* file = fopen(pidFile.c_str(), "w");
if (file = fopen(pidFile.c_str(), "w")) if (file)
{ {
fprintf(file, "%d\n", pid); fprintf(file, "%d\n", pid);
fclose(file); fclose(file);
@ -790,7 +790,9 @@ void ShrinkDebugFile()
fseek(file, -sizeof(pch), SEEK_END); fseek(file, -sizeof(pch), SEEK_END);
int nBytes = fread(pch, 1, sizeof(pch), file); int nBytes = fread(pch, 1, sizeof(pch), file);
fclose(file); fclose(file);
if (file = fopen(strFile.c_str(), "w"))
file = fopen(strFile.c_str(), "w");
if (file)
{ {
fwrite(pch, 1, nBytes, file); fwrite(pch, 1, nBytes, file);
fclose(file); fclose(file);

View File

@ -264,7 +264,7 @@ public:
// I'd rather be careful than suffer the other more error prone syntax. // I'd rather be careful than suffer the other more error prone syntax.
// The compiler will optimise away all this loop junk. // The compiler will optimise away all this loop junk.
#define CRITICAL_BLOCK(cs) \ #define CRITICAL_BLOCK(cs) \
for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!", !fcriticalblockonce)), fcriticalblockonce=false) \ for (bool fcriticalblockonce=true; fcriticalblockonce; assert("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce), fcriticalblockonce=false) \
for (CCriticalBlock criticalblock(cs); fcriticalblockonce && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0) for (CCriticalBlock criticalblock(cs); fcriticalblockonce && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0)
class CTryCriticalBlock class CTryCriticalBlock
@ -278,7 +278,7 @@ public:
}; };
#define TRY_CRITICAL_BLOCK(cs) \ #define TRY_CRITICAL_BLOCK(cs) \
for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by TRY_CRITICAL_BLOCK!", !fcriticalblockonce)), fcriticalblockonce=false) \ for (bool fcriticalblockonce=true; fcriticalblockonce; assert("break caught by TRY_CRITICAL_BLOCK!" && !fcriticalblockonce), fcriticalblockonce=false) \
for (CTryCriticalBlock criticalblock(cs); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()) && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0) for (CTryCriticalBlock criticalblock(cs); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()) && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0)
@ -648,7 +648,7 @@ inline bool TerminateThread(pthread_t hthread, unsigned int nExitCode)
return (pthread_cancel(hthread) == 0); return (pthread_cancel(hthread) == 0);
} }
inline void ExitThread(unsigned int nExitCode) inline void ExitThread(size_t nExitCode)
{ {
pthread_exit((void*)nExitCode); pthread_exit((void*)nExitCode);
} }

View File

@ -722,8 +722,6 @@ void CWallet::ResendWalletTransactions()
int64 CWallet::GetBalance() const int64 CWallet::GetBalance() const
{ {
int64 nStart = GetTimeMillis();
int64 nTotal = 0; int64 nTotal = 0;
CRITICAL_BLOCK(cs_mapWallet) CRITICAL_BLOCK(cs_mapWallet)
{ {
@ -736,7 +734,6 @@ int64 CWallet::GetBalance() const
} }
} }
//printf("GetBalance() %"PRI64d"ms\n", GetTimeMillis() - nStart);
return nTotal; return nTotal;
} }