Clean up warnings
* Use -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameters * Remove xCXXFLAGS usage in makefile.unix * Fix several recent and older sign-compare warnings
This commit is contained in:
parent
781fc2c8c0
commit
f621326c24
@ -90,7 +90,7 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) {
|
|||||||
DEFINES += HAVE_BUILD_INFO
|
DEFINES += HAVE_BUILD_INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-invalid-offsetof -Wno-sign-compare -Wno-unused-parameter
|
QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
DEPENDPATH += src src/json src/qt
|
DEPENDPATH += src src/json src/qt
|
||||||
|
@ -102,12 +102,11 @@ CAddrInfo* CAddrMan::Create(const CAddress &addr, const CNetAddr &addrSource, in
|
|||||||
return &mapInfo[nId];
|
return &mapInfo[nId];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAddrMan::SwapRandom(int nRndPos1, int nRndPos2)
|
void CAddrMan::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2)
|
||||||
{
|
{
|
||||||
if (nRndPos1 == nRndPos2)
|
if (nRndPos1 == nRndPos2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(nRndPos1 >= 0 && nRndPos2 >= 0);
|
|
||||||
assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size());
|
assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size());
|
||||||
|
|
||||||
int nId1 = vRandom[nRndPos1];
|
int nId1 = vRandom[nRndPos1];
|
||||||
@ -149,7 +148,7 @@ int CAddrMan::SelectTried(int nKBucket)
|
|||||||
|
|
||||||
int CAddrMan::ShrinkNew(int nUBucket)
|
int CAddrMan::ShrinkNew(int nUBucket)
|
||||||
{
|
{
|
||||||
assert(nUBucket >= 0 && nUBucket < vvNew.size());
|
assert(nUBucket >= 0 && (unsigned int)nUBucket < vvNew.size());
|
||||||
std::set<int> &vNew = vvNew[nUBucket];
|
std::set<int> &vNew = vvNew[nUBucket];
|
||||||
|
|
||||||
// first look for deletable items
|
// first look for deletable items
|
||||||
|
@ -204,7 +204,7 @@ protected:
|
|||||||
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL);
|
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL);
|
||||||
|
|
||||||
// Swap two elements in vRandom.
|
// Swap two elements in vRandom.
|
||||||
void SwapRandom(int nRandomPos1, int nRandomPos2);
|
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2);
|
||||||
|
|
||||||
// Return position in given bucket to replace.
|
// Return position in given bucket to replace.
|
||||||
int SelectTried(int nKBucket);
|
int SelectTried(int nKBucket);
|
||||||
|
@ -2060,7 +2060,7 @@ bool LoadExternalBlockFile(FILE* fileIn)
|
|||||||
try {
|
try {
|
||||||
CAutoFile blkdat(fileIn, SER_DISK, CLIENT_VERSION);
|
CAutoFile blkdat(fileIn, SER_DISK, CLIENT_VERSION);
|
||||||
unsigned int nPos = 0;
|
unsigned int nPos = 0;
|
||||||
while (nPos != -1 && blkdat.good() && !fRequestShutdown)
|
while (nPos != (unsigned int)-1 && blkdat.good() && !fRequestShutdown)
|
||||||
{
|
{
|
||||||
unsigned char pchData[65536];
|
unsigned char pchData[65536];
|
||||||
do {
|
do {
|
||||||
@ -2068,7 +2068,7 @@ bool LoadExternalBlockFile(FILE* fileIn)
|
|||||||
int nRead = fread(pchData, 1, sizeof(pchData), blkdat);
|
int nRead = fread(pchData, 1, sizeof(pchData), blkdat);
|
||||||
if (nRead <= 8)
|
if (nRead <= 8)
|
||||||
{
|
{
|
||||||
nPos = -1;
|
nPos = (unsigned int)-1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
void* nFind = memchr(pchData, pchMessageStart[0], nRead+1-sizeof(pchMessageStart));
|
void* nFind = memchr(pchData, pchMessageStart[0], nRead+1-sizeof(pchMessageStart));
|
||||||
@ -2084,7 +2084,7 @@ bool LoadExternalBlockFile(FILE* fileIn)
|
|||||||
else
|
else
|
||||||
nPos += sizeof(pchData) - sizeof(pchMessageStart) + 1;
|
nPos += sizeof(pchData) - sizeof(pchMessageStart) + 1;
|
||||||
} while(!fRequestShutdown);
|
} while(!fRequestShutdown);
|
||||||
if (nPos == -1)
|
if (nPos == (unsigned int)-1)
|
||||||
break;
|
break;
|
||||||
fseek(blkdat, nPos, SEEK_SET);
|
fseek(blkdat, nPos, SEEK_SET);
|
||||||
unsigned int nSize;
|
unsigned int nSize;
|
||||||
|
@ -36,7 +36,7 @@ static const int64 MAX_MONEY = 21000000 * COIN;
|
|||||||
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
||||||
static const int COINBASE_MATURITY = 100;
|
static const int COINBASE_MATURITY = 100;
|
||||||
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
|
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
|
||||||
static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
|
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
static const int fHaveUPnP = true;
|
static const int fHaveUPnP = true;
|
||||||
#else
|
#else
|
||||||
|
@ -29,7 +29,7 @@ LIBS= \
|
|||||||
|
|
||||||
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
|
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
|
||||||
DEBUGFLAGS=-g
|
DEBUGFLAGS=-g
|
||||||
CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||||
|
|
||||||
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ LIBS= \
|
|||||||
|
|
||||||
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
|
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
|
||||||
DEBUGFLAGS=-g
|
DEBUGFLAGS=-g
|
||||||
CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||||
|
|
||||||
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ CFLAGS = -g
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# ppc doesn't work because we don't support big-endian
|
# ppc doesn't work because we don't support big-endian
|
||||||
CFLAGS += -Wextra -Wno-sign-compare -Wno-invalid-offsetof -Wformat-security \
|
CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-paramter \
|
||||||
$(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
$(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||||
|
|
||||||
OBJS= \
|
OBJS= \
|
||||||
|
@ -82,9 +82,8 @@ LIBS+= \
|
|||||||
|
|
||||||
|
|
||||||
DEBUGFLAGS=-g
|
DEBUGFLAGS=-g
|
||||||
CXXFLAGS=-O2
|
CXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
|
||||||
xCXXFLAGS=-pthread -Wall -Wextra -Wno-invalid-offsetof -Wno-unused-parameter -Wformat -Wformat-security \
|
$(DEBUGFLAGS) $(DEFS) $(HARDENING)
|
||||||
$(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
|
|
||||||
|
|
||||||
OBJS= \
|
OBJS= \
|
||||||
obj/version.o \
|
obj/version.o \
|
||||||
@ -121,26 +120,26 @@ version.cpp: obj/build.h
|
|||||||
DEFS += -DHAVE_BUILD_INFO
|
DEFS += -DHAVE_BUILD_INFO
|
||||||
|
|
||||||
obj/%.o: %.cpp
|
obj/%.o: %.cpp
|
||||||
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
|
$(CXX) -c $(CXXFLAGS) -MMD -o $@ $<
|
||||||
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
|
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
|
||||||
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
||||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
|
||||||
rm -f $(@:%.o=%.d)
|
rm -f $(@:%.o=%.d)
|
||||||
|
|
||||||
bitcoind: $(OBJS:obj/%=obj/%)
|
bitcoind: $(OBJS:obj/%=obj/%)
|
||||||
$(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
|
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
|
||||||
|
|
||||||
obj-test/%.o: test/%.cpp
|
obj-test/%.o: test/%.cpp
|
||||||
$(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $<
|
$(CXX) -c $(TESTDEFS) $(CXXFLAGS) -MMD -o $@ $<
|
||||||
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
|
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
|
||||||
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
||||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
|
||||||
rm -f $(@:%.o=%.d)
|
rm -f $(@:%.o=%.d)
|
||||||
|
|
||||||
test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||||
$(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
|
$(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f bitcoind test_bitcoin
|
-rm -f bitcoind test_bitcoin
|
||||||
|
@ -208,9 +208,9 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
|
|||||||
}
|
}
|
||||||
char pszSocks5Init[] = "\5\1\0";
|
char pszSocks5Init[] = "\5\1\0";
|
||||||
char *pszSocks5 = pszSocks5Init;
|
char *pszSocks5 = pszSocks5Init;
|
||||||
int nSize = sizeof(pszSocks5Init);
|
ssize_t nSize = sizeof(pszSocks5Init);
|
||||||
|
|
||||||
int ret = send(hSocket, pszSocks5, nSize, MSG_NOSIGNAL);
|
ssize_t ret = send(hSocket, pszSocks5, nSize, MSG_NOSIGNAL);
|
||||||
if (ret != nSize)
|
if (ret != nSize)
|
||||||
{
|
{
|
||||||
closesocket(hSocket);
|
closesocket(hSocket);
|
||||||
@ -234,7 +234,7 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
|
|||||||
strSocks5 += static_cast<char>((port >> 8) & 0xFF);
|
strSocks5 += static_cast<char>((port >> 8) & 0xFF);
|
||||||
strSocks5 += static_cast<char>((port >> 0) & 0xFF);
|
strSocks5 += static_cast<char>((port >> 0) & 0xFF);
|
||||||
ret = send(hSocket, strSocks5.c_str(), strSocks5.size(), MSG_NOSIGNAL);
|
ret = send(hSocket, strSocks5.c_str(), strSocks5.size(), MSG_NOSIGNAL);
|
||||||
if (ret != strSocks5.size())
|
if (ret != (ssize_t)strSocks5.size())
|
||||||
{
|
{
|
||||||
closesocket(hSocket);
|
closesocket(hSocket);
|
||||||
return error("Error sending to proxy");
|
return error("Error sending to proxy");
|
||||||
|
@ -102,7 +102,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
|||||||
//
|
//
|
||||||
int64 nTxFee = nDebit - wtx.GetValueOut();
|
int64 nTxFee = nDebit - wtx.GetValueOut();
|
||||||
|
|
||||||
for (int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
||||||
{
|
{
|
||||||
const CTxOut& txout = wtx.vout[nOut];
|
const CTxOut& txout = wtx.vout[nOut];
|
||||||
TransactionRecord sub(hash, nTime);
|
TransactionRecord sub(hash, nTime);
|
||||||
|
@ -67,7 +67,7 @@ const char *vstrOut[] = {
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
|
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
|
||||||
{
|
{
|
||||||
for (int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
|
for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL(EncodeBase58(vstrIn[i].data, vstrIn[i].data + vstrIn[i].size), vstrOut[i]);
|
BOOST_CHECK_EQUAL(EncodeBase58(vstrIn[i].data, vstrIn[i].data + vstrIn[i].size), vstrOut[i]);
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
|
|||||||
BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
|
BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> result;
|
std::vector<unsigned char> result;
|
||||||
for (int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
|
for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> expected(vstrIn[i].data, vstrIn[i].data + vstrIn[i].size);
|
std::vector<unsigned char> expected(vstrIn[i].data, vstrIn[i].data + vstrIn[i].size);
|
||||||
BOOST_CHECK(DecodeBase58(vstrOut[i], result));
|
BOOST_CHECK(DecodeBase58(vstrOut[i], result));
|
||||||
|
@ -10,7 +10,7 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
|
|||||||
{
|
{
|
||||||
static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
|
static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
|
||||||
static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"};
|
static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"};
|
||||||
for (int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
|
for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
|
||||||
{
|
{
|
||||||
std::string strEnc = EncodeBase64(vstrIn[i]);
|
std::string strEnc = EncodeBase64(vstrIn[i]);
|
||||||
BOOST_CHECK(strEnc == vstrOut[i]);
|
BOOST_CHECK(strEnc == vstrOut[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user