From 050d2e953f23db6d818b9cec6b7dc0e52aa7537c Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 31 Jul 2013 14:06:44 +1000 Subject: [PATCH] Remove #define loop from util.h Replace the loop macro with while (true). The #define caused problems for Qt. --- src/bitcoinrpc.cpp | 2 +- src/main.cpp | 4 ++-- src/net.cpp | 12 ++++++------ src/qt/bitcoin.cpp | 1 - src/qt/bitcoingui.cpp | 1 - src/qt/guiutil.cpp | 1 - src/qt/paymentserver.cpp | 1 - src/qt/splashscreen.cpp | 1 - src/script.cpp | 2 +- src/util.cpp | 8 ++++---- src/util.h | 1 - src/wallet.cpp | 2 +- src/walletdb.cpp | 4 ++-- 13 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 11fac422..7a3e6560 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -414,7 +414,7 @@ int ReadHTTPStatus(std::basic_istream& stream, int &proto) int ReadHTTPHeaders(std::basic_istream& stream, map& mapHeadersRet) { int nLen = 0; - loop + while (true) { string str; std::getline(stream, str); diff --git a/src/main.cpp b/src/main.cpp index d3589144..39e1a515 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4615,7 +4615,7 @@ void static BitcoinMiner(CWallet *pwallet) CReserveKey reservekey(pwallet); unsigned int nExtraNonce = 0; - try { loop { + try { while (true) { if (Params().NetworkID() != CChainParams::REGTEST) { // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. @@ -4659,7 +4659,7 @@ void static BitcoinMiner(CWallet *pwallet) uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); uint256 hashbuf[2]; uint256& hash = *alignup<16>(hashbuf); - loop + while (true) { unsigned int nHashesDone = 0; unsigned int nNonceFound; diff --git a/src/net.cpp b/src/net.cpp index bd9aa1f5..4ee1895a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -129,7 +129,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer) bool RecvLine(SOCKET hSocket, string& strLine) { strLine = ""; - loop + while (true) { char c; int nBytes = recv(hSocket, &c, 1, 0); @@ -301,7 +301,7 @@ bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const cha { if (strLine.empty()) // HTTP response is separated from headers by blank line { - loop + while (true) { if (!RecvLine(hSocket, strLine)) { @@ -741,7 +741,7 @@ static list vNodesDisconnected; void ThreadSocketHandler() { unsigned int nPrevNodeCount = 0; - loop + while (true) { // // Disconnect nodes @@ -1105,7 +1105,7 @@ void ThreadMapPort() string strDesc = "Bitcoin " + FormatFullVersion(); try { - loop { + while (true) { #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, @@ -1268,7 +1268,7 @@ void ThreadOpenConnections() // Initiate network connections int64 nStart = GetTime(); - loop + while (true) { ProcessOneShot(); @@ -1309,7 +1309,7 @@ void ThreadOpenConnections() int64 nANow = GetAdjustedTime(); int nTries = 0; - loop + while (true) { // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections) CAddress addr = addrman.Select(10 + min(nOutbound,8)*10); diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 4e9180b8..3b983346 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -15,7 +15,6 @@ #include "splashscreen.h" #include "intro.h" -#undef loop /* Todo: ugh, remove this when the #define loop is gone from util.h */ #include #include #if QT_VERSION < 0x050000 diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 11767cf3..4ed734b9 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -28,7 +28,6 @@ #include "macdockiconhandler.h" #endif -#undef loop /* Todo: ugh, remove this when the #define loop is gone from util.h */ #include #include #include diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 521d9bdd..0ea5060e 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -7,7 +7,6 @@ #include "util.h" #include "init.h" -#undef loop /* Todo: ugh, remove this when the #define loop is gone from util.h */ #include #include #include diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 8178065b..0d31f24a 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -8,7 +8,6 @@ #include "ui_interface.h" #include "util.h" -#undef loop /* Todo: ugh, remove this when the #define loop is gone from util.h */ #include #include #include diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 43430a85..22cf0448 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -2,7 +2,6 @@ #include "clientversion.h" #include "util.h" -#undef loop /* Todo: ugh, remove this when the #define loop is gone from util.h */ #include #include diff --git a/src/script.cpp b/src/script.cpp index 14fe80e2..5699fbfb 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1163,7 +1163,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector& v) return; string::size_type i1 = 0; string::size_type i2; - loop + while (true) { i2 = str.find(c, i1); if (i2 == str.npos) @@ -487,7 +487,7 @@ vector ParseHex(const char* psz) { // convert hex dump to vector vector vch; - loop + while (true) { while (isspace(*psz)) psz++; @@ -941,7 +941,7 @@ string DecodeBase32(const string& str) bool WildcardMatch(const char* psz, const char* mask) { - loop + while (true) { switch (*mask) { diff --git a/src/util.h b/src/util.h index bee2749c..9ca73f33 100644 --- a/src/util.h +++ b/src/util.h @@ -35,7 +35,6 @@ typedef unsigned long long uint64; static const int64 COIN = 100000000; static const int64 CENT = 1000000; -#define loop for (;;) #define BEGIN(a) ((char*)&(a)) #define END(a) ((char*)&((&(a))[1])) #define UBEGIN(a) ((unsigned char*)&(a)) diff --git a/src/wallet.cpp b/src/wallet.cpp index 0b4c866f..88b07c9d 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1194,7 +1194,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, LOCK2(cs_main, cs_wallet); { nFeeRet = nTransactionFee; - loop + while (true) { wtxNew.vin.clear(); wtxNew.vout.clear(); diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 7aad7797..014d8cbe 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -73,7 +73,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list