aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-01-12 20:02:47 -0500
committerGavin Andresen <gavinandresen@gmail.com>2012-01-12 20:02:47 -0500
commita1de57a063af397612bb77f87c803c578d04f8e5 (patch)
tree89195dc59b21098e0d747d88e2f4c1ee6ba9d9f0
parent025d495481f2313a1550d8d101415ff3e3a6b89f (diff)
Compile with extra warnings turned on. And more makefile/code tidying up.
This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings. Exceptions are: -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned. -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit).
-rw-r--r--src/bitcoinrpc.cpp2
-rw-r--r--src/checkpoints.cpp1
-rw-r--r--src/headers.h2
-rw-r--r--src/makefile.linux-mingw7
-rw-r--r--src/makefile.mingw6
-rw-r--r--src/makefile.osx14
-rw-r--r--src/makefile.unix13
-rw-r--r--src/net.cpp3
-rw-r--r--src/net.h4
-rw-r--r--src/netbase.cpp4
-rw-r--r--src/serialize.h3
11 files changed, 29 insertions, 30 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index ce29840194..67edf8d8b7 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1418,7 +1418,7 @@ Value listsinceblock(const Array& params, bool fHelp)
CBlockIndex *block;
for (block = pindexBest;
block && block->nHeight > target_height;
- block = block->pprev);
+ block = block->pprev) { }
lastblock = block ? block->GetBlockHash() : 0;
}
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp
index c7e054df37..508f72b376 100644
--- a/src/checkpoints.cpp
+++ b/src/checkpoints.cpp
@@ -52,7 +52,6 @@ namespace Checkpoints
{
if (fTestNet) return NULL;
- int64 nResult;
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
{
const uint256& hash = i.second;
diff --git a/src/headers.h b/src/headers.h
index 6a2a3e4ca4..127cf41282 100644
--- a/src/headers.h
+++ b/src/headers.h
@@ -79,8 +79,6 @@
#endif
-#pragma hdrstop
-
#include "serialize.h"
#include "uint256.h"
#include "util.h"
diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw
index 5868a180c5..9212698018 100644
--- a/src/makefile.linux-mingw
+++ b/src/makefile.linux-mingw
@@ -62,23 +62,22 @@ OBJS= \
all: bitcoind.exe
-obj/nogui/%.o: %.cpp $(HEADERS)
+obj/%.o: %.cpp $(HEADERS)
i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
-bitcoind.exe: $(OBJS:obj/%=obj/nogui/%)
+bitcoind.exe: $(OBJS:obj/%=obj/%)
i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
obj/test/%.o: obj/test/%.cpp $(HEADERS)
i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
-test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
+test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s
clean:
-rm -f obj/*.o
- -rm -f obj/nogui/*.o
-rm -f obj/test/*.o
-rm -f test/*.o
-rm -f headers.h.gch
diff --git a/src/makefile.mingw b/src/makefile.mingw
index 0837940152..c55e17a36e 100644
--- a/src/makefile.mingw
+++ b/src/makefile.mingw
@@ -61,16 +61,16 @@ OBJS= \
all: bitcoind.exe
-obj/nogui/%.o: %.cpp $(HEADERS)
+obj/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $<
-bitcoind.exe: $(OBJS:obj/%=obj/nogui/%)
+bitcoind.exe: $(OBJS:obj/%=obj/%)
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
g++ -c $(CFLAGS) -o $@ test/test_bitcoin.cpp
-test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
+test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
clean:
diff --git a/src/makefile.osx b/src/makefile.osx
index 78ecdb8d90..fd60f6233d 100644
--- a/src/makefile.osx
+++ b/src/makefile.osx
@@ -46,7 +46,9 @@ DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DUSE_SSL
DEBUGFLAGS=-g
# ppc doesn't work because we don't support big-endian
-CFLAGS=-mmacosx-version-min=10.5 -arch i386 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+CFLAGS=-mmacosx-version-min=10.5 -arch i386 -O3 \
+ -Wextra -Wno-sign-compare -Wno-char-subscripts -Wno-invalid-offsetof -Wformat-security \
+ $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
OBJS= \
obj/checkpoints.o \
@@ -78,17 +80,17 @@ endif
all: bitcoind
# auto-generated dependencies:
--include obj/nogui/*.P
+-include obj/*.P
-include obj/test/*.P
-obj/nogui/%.o: %.cpp
+obj/%.o: %.cpp
$(CXX) -c $(CFLAGS) -MMD -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
-bitcoind: $(OBJS:obj/%=obj/nogui/%)
+bitcoind: $(OBJS:obj/%=obj/%)
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp))
@@ -100,14 +102,12 @@ obj/test/%.o: test/%.cpp
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
-test_bitcoin: $(TESTOBJS) $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
+test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
clean:
-rm -f bitcoind test_bitcoin
-rm -f obj/*.o
- -rm -f obj/nogui/*.o
-rm -f obj/test/*.o
-rm -f obj/*.P
- -rm -f obj/nogui/*.P
-rm -f obj/test/*.P
diff --git a/src/makefile.unix b/src/makefile.unix
index dad100db10..3c6be3ee41 100644
--- a/src/makefile.unix
+++ b/src/makefile.unix
@@ -83,7 +83,8 @@ LIBS+= \
DEBUGFLAGS=-g
CXXFLAGS=-O2
-xCXXFLAGS=-pthread -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
+xCXXFLAGS=-pthread -Wextra -Wno-sign-compare -Wno-char-subscripts -Wno-invalid-offsetof -Wformat-security \
+ $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
OBJS= \
obj/checkpoints.o \
@@ -107,17 +108,17 @@ OBJS= \
all: bitcoind
# auto-generated dependencies:
--include obj/nogui/*.P
+-include obj/*.P
-include obj/test/*.P
-obj/nogui/%.o: %.cpp
+obj/%.o: %.cpp
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
-bitcoind: $(OBJS:obj/%=obj/nogui/%)
+bitcoind: $(OBJS:obj/%=obj/%)
$(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp))
@@ -129,14 +130,12 @@ obj/test/%.o: test/%.cpp
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
-test_bitcoin: $(TESTOBJS) $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
+test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
$(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
clean:
-rm -f bitcoind test_bitcoin
-rm -f obj/*.o
- -rm -f obj/nogui/*.o
-rm -f obj/test/*.o
-rm -f obj/*.P
- -rm -f obj/nogui/*.P
-rm -f obj/test/*.P
diff --git a/src/net.cpp b/src/net.cpp
index 72897687ef..817203b013 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -938,7 +938,6 @@ void ThreadMapPort2(void* parg)
char port[6];
sprintf(port, "%d", GetListenPort());
- const char * rootdescurl = 0;
const char * multicastif = 0;
const char * minissdpdpath = 0;
struct UPNPDev * devlist = 0;
@@ -960,8 +959,6 @@ void ThreadMapPort2(void* parg)
r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
if (r == 1)
{
- char intClient[16];
- char intPort[6];
string strDesc = "Bitcoin " + FormatFullVersion();
#ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
diff --git a/src/net.h b/src/net.h
index 61daf0378c..9f58d1e5d3 100644
--- a/src/net.h
+++ b/src/net.h
@@ -266,7 +266,9 @@ public:
// Make sure not to reuse time indexes to keep things in the same order
int64 nNow = (GetTime() - 1) * 1000000;
static int64 nLastTime;
- nLastTime = nNow = std::max(nNow, ++nLastTime);
+ ++nLastTime;
+ nNow = std::max(nNow, nLastTime);
+ nLastTime = nNow;
// Each retry is 2 minutes after the last
nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 2c4df7faf8..ca27c2a8ce 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -25,7 +25,9 @@ static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0
bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions, bool fAllowLookup)
{
vIP.clear();
- struct addrinfo aiHint = {};
+ struct addrinfo aiHint;
+ memset(&aiHint, 0, sizeof(struct addrinfo));
+
aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP;
#ifdef WIN32
diff --git a/src/serialize.h b/src/serialize.h
index 626f7d6eff..c9dbdf7f9d 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -89,6 +89,7 @@ enum
const bool fRead = false; \
unsigned int nSerSize = 0; \
ser_streamplaceholder s; \
+ assert(fGetSize||fWrite||fRead); /* suppress warning */ \
s.nType = nType; \
s.nVersion = nVersion; \
{statements} \
@@ -102,6 +103,7 @@ enum
const bool fWrite = true; \
const bool fRead = false; \
unsigned int nSerSize = 0; \
+ assert(fGetSize||fWrite||fRead); /* suppress warning */ \
{statements} \
} \
template<typename Stream> \
@@ -112,6 +114,7 @@ enum
const bool fWrite = false; \
const bool fRead = true; \
unsigned int nSerSize = 0; \
+ assert(fGetSize||fWrite||fRead); /* suppress warning */ \
{statements} \
}