Skip to content

Commit 2e76741

Browse files
committed
Merge pull request #1230 from sipa/warnings
Clean up warnings
2 parents c164396 + f621326 commit 2e76741

13 files changed

+24
-26
lines changed

bitcoin-qt.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) {
9090
DEFINES += HAVE_BUILD_INFO
9191
}
9292

93-
QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-invalid-offsetof -Wno-sign-compare -Wno-unused-parameter
93+
QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter
9494

9595
# Input
9696
DEPENDPATH += src src/json src/qt

src/addrman.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,11 @@ CAddrInfo* CAddrMan::Create(const CAddress &addr, const CNetAddr &addrSource, in
102102
return &mapInfo[nId];
103103
}
104104

105-
void CAddrMan::SwapRandom(int nRndPos1, int nRndPos2)
105+
void CAddrMan::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2)
106106
{
107107
if (nRndPos1 == nRndPos2)
108108
return;
109109

110-
assert(nRndPos1 >= 0 && nRndPos2 >= 0);
111110
assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size());
112111

113112
int nId1 = vRandom[nRndPos1];
@@ -149,7 +148,7 @@ int CAddrMan::SelectTried(int nKBucket)
149148

150149
int CAddrMan::ShrinkNew(int nUBucket)
151150
{
152-
assert(nUBucket >= 0 && nUBucket < vvNew.size());
151+
assert(nUBucket >= 0 && (unsigned int)nUBucket < vvNew.size());
153152
std::set<int> &vNew = vvNew[nUBucket];
154153

155154
// first look for deletable items

src/addrman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class CAddrMan
204204
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL);
205205

206206
// Swap two elements in vRandom.
207-
void SwapRandom(int nRandomPos1, int nRandomPos2);
207+
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2);
208208

209209
// Return position in given bucket to replace.
210210
int SelectTried(int nKBucket);

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,15 +2060,15 @@ bool LoadExternalBlockFile(FILE* fileIn)
20602060
try {
20612061
CAutoFile blkdat(fileIn, SER_DISK, CLIENT_VERSION);
20622062
unsigned int nPos = 0;
2063-
while (nPos != -1 && blkdat.good() && !fRequestShutdown)
2063+
while (nPos != (unsigned int)-1 && blkdat.good() && !fRequestShutdown)
20642064
{
20652065
unsigned char pchData[65536];
20662066
do {
20672067
fseek(blkdat, nPos, SEEK_SET);
20682068
int nRead = fread(pchData, 1, sizeof(pchData), blkdat);
20692069
if (nRead <= 8)
20702070
{
2071-
nPos = -1;
2071+
nPos = (unsigned int)-1;
20722072
break;
20732073
}
20742074
void* nFind = memchr(pchData, pchMessageStart[0], nRead+1-sizeof(pchMessageStart));
@@ -2084,7 +2084,7 @@ bool LoadExternalBlockFile(FILE* fileIn)
20842084
else
20852085
nPos += sizeof(pchData) - sizeof(pchMessageStart) + 1;
20862086
} while(!fRequestShutdown);
2087-
if (nPos == -1)
2087+
if (nPos == (unsigned int)-1)
20882088
break;
20892089
fseek(blkdat, nPos, SEEK_SET);
20902090
unsigned int nSize;

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static const int64 MAX_MONEY = 21000000 * COIN;
3636
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
3737
static const int COINBASE_MATURITY = 100;
3838
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
39-
static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
39+
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
4040
#ifdef USE_UPNP
4141
static const int fHaveUPnP = true;
4242
#else

src/makefile.linux-mingw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LIBS= \
2929

3030
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
3131
DEBUGFLAGS=-g
32-
CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
32+
CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
3333

3434
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
3535

src/makefile.mingw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LIBS= \
2525

2626
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
2727
DEBUGFLAGS=-g
28-
CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
28+
CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
2929

3030
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
3131

src/makefile.osx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CFLAGS = -g
6565
endif
6666

6767
# ppc doesn't work because we don't support big-endian
68-
CFLAGS += -Wextra -Wno-sign-compare -Wno-invalid-offsetof -Wformat-security \
68+
CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-paramter \
6969
$(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
7070

7171
OBJS= \

src/makefile.unix

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ LIBS+= \
8282

8383

8484
DEBUGFLAGS=-g
85-
CXXFLAGS=-O2
86-
xCXXFLAGS=-pthread -Wall -Wextra -Wno-invalid-offsetof -Wno-unused-parameter -Wformat -Wformat-security \
87-
$(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
85+
CXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
86+
$(DEBUGFLAGS) $(DEFS) $(HARDENING)
8887

8988
OBJS= \
9089
obj/version.o \
@@ -121,26 +120,26 @@ version.cpp: obj/build.h
121120
DEFS += -DHAVE_BUILD_INFO
122121

123122
obj/%.o: %.cpp
124-
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
123+
$(CXX) -c $(CXXFLAGS) -MMD -o $@ $<
125124
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
126125
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
127126
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
128127
rm -f $(@:%.o=%.d)
129128

130129
bitcoind: $(OBJS:obj/%=obj/%)
131-
$(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
130+
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
132131

133132
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
134133

135134
obj-test/%.o: test/%.cpp
136-
$(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $<
135+
$(CXX) -c $(TESTDEFS) $(CXXFLAGS) -MMD -o $@ $<
137136
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
138137
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
139138
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
140139
rm -f $(@:%.o=%.d)
141140

142141
test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
143-
$(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
142+
$(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
144143

145144
clean:
146145
-rm -f bitcoind test_bitcoin

src/netbase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
208208
}
209209
char pszSocks5Init[] = "\5\1\0";
210210
char *pszSocks5 = pszSocks5Init;
211-
int nSize = sizeof(pszSocks5Init);
211+
ssize_t nSize = sizeof(pszSocks5Init);
212212

213-
int ret = send(hSocket, pszSocks5, nSize, MSG_NOSIGNAL);
213+
ssize_t ret = send(hSocket, pszSocks5, nSize, MSG_NOSIGNAL);
214214
if (ret != nSize)
215215
{
216216
closesocket(hSocket);
@@ -234,7 +234,7 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
234234
strSocks5 += static_cast<char>((port >> 8) & 0xFF);
235235
strSocks5 += static_cast<char>((port >> 0) & 0xFF);
236236
ret = send(hSocket, strSocks5.c_str(), strSocks5.size(), MSG_NOSIGNAL);
237-
if (ret != strSocks5.size())
237+
if (ret != (ssize_t)strSocks5.size())
238238
{
239239
closesocket(hSocket);
240240
return error("Error sending to proxy");

0 commit comments

Comments
 (0)