Browse Source

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).
0.8
Gavin Andresen 13 years ago
parent
commit
a1de57a063
  1. 2
      src/bitcoinrpc.cpp
  2. 1
      src/checkpoints.cpp
  3. 2
      src/headers.h
  4. 7
      src/makefile.linux-mingw
  5. 6
      src/makefile.mingw
  6. 14
      src/makefile.osx
  7. 13
      src/makefile.unix
  8. 3
      src/net.cpp
  9. 4
      src/net.h
  10. 4
      src/netbase.cpp
  11. 3
      src/serialize.h

2
src/bitcoinrpc.cpp

@ -1418,7 +1418,7 @@ Value listsinceblock(const Array& params, bool fHelp)
CBlockIndex *block; CBlockIndex *block;
for (block = pindexBest; for (block = pindexBest;
block && block->nHeight > target_height; block && block->nHeight > target_height;
block = block->pprev); block = block->pprev) { }
lastblock = block ? block->GetBlockHash() : 0; lastblock = block ? block->GetBlockHash() : 0;
} }

1
src/checkpoints.cpp

@ -52,7 +52,6 @@ namespace Checkpoints
{ {
if (fTestNet) return NULL; if (fTestNet) return NULL;
int64 nResult;
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
{ {
const uint256& hash = i.second; const uint256& hash = i.second;

2
src/headers.h

@ -79,8 +79,6 @@
#endif #endif
#pragma hdrstop
#include "serialize.h" #include "serialize.h"
#include "uint256.h" #include "uint256.h"
#include "util.h" #include "util.h"

7
src/makefile.linux-mingw

@ -62,23 +62,22 @@ OBJS= \
all: bitcoind.exe all: bitcoind.exe
obj/nogui/%.o: %.cpp $(HEADERS) obj/%.o: %.cpp $(HEADERS)
i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) bitcoind.exe: $(OBJS:obj/%=obj/%)
i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
obj/test/%.o: obj/test/%.cpp $(HEADERS) obj/test/%.o: obj/test/%.cpp $(HEADERS)
i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< 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 i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s
clean: clean:
-rm -f obj/*.o -rm -f obj/*.o
-rm -f obj/nogui/*.o
-rm -f obj/test/*.o -rm -f obj/test/*.o
-rm -f test/*.o -rm -f test/*.o
-rm -f headers.h.gch -rm -f headers.h.gch

6
src/makefile.mingw

@ -61,16 +61,16 @@ OBJS= \
all: bitcoind.exe all: bitcoind.exe
obj/nogui/%.o: %.cpp $(HEADERS) obj/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) bitcoind.exe: $(OBJS:obj/%=obj/%)
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
g++ -c $(CFLAGS) -o $@ test/test_bitcoin.cpp 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) g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
clean: clean:

14
src/makefile.osx vendored

@ -46,7 +46,9 @@ DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DUSE_SSL
DEBUGFLAGS=-g DEBUGFLAGS=-g
# ppc doesn't work because we don't support big-endian # 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= \ OBJS= \
obj/checkpoints.o \ obj/checkpoints.o \
@ -78,17 +80,17 @@ endif
all: bitcoind all: bitcoind
# auto-generated dependencies: # auto-generated dependencies:
-include obj/nogui/*.P -include obj/*.P
-include obj/test/*.P -include obj/test/*.P
obj/nogui/%.o: %.cpp obj/%.o: %.cpp
$(CXX) -c $(CFLAGS) -MMD -o $@ $< $(CXX) -c $(CFLAGS) -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/nogui/%) bitcoind: $(OBJS:obj/%=obj/%)
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp)) 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); \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d) 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 $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
clean: clean:
-rm -f bitcoind test_bitcoin -rm -f bitcoind test_bitcoin
-rm -f obj/*.o -rm -f obj/*.o
-rm -f obj/nogui/*.o
-rm -f obj/test/*.o -rm -f obj/test/*.o
-rm -f obj/*.P -rm -f obj/*.P
-rm -f obj/nogui/*.P
-rm -f obj/test/*.P -rm -f obj/test/*.P

13
src/makefile.unix

@ -83,7 +83,8 @@ LIBS+= \
DEBUGFLAGS=-g DEBUGFLAGS=-g
CXXFLAGS=-O2 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= \ OBJS= \
obj/checkpoints.o \ obj/checkpoints.o \
@ -107,17 +108,17 @@ OBJS= \
all: bitcoind all: bitcoind
# auto-generated dependencies: # auto-generated dependencies:
-include obj/nogui/*.P -include obj/*.P
-include obj/test/*.P -include obj/test/*.P
obj/nogui/%.o: %.cpp obj/%.o: %.cpp
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< $(CXX) -c $(xCXXFLAGS) -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/nogui/%) bitcoind: $(OBJS:obj/%=obj/%)
$(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp)) 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); \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d) 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) $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
clean: clean:
-rm -f bitcoind test_bitcoin -rm -f bitcoind test_bitcoin
-rm -f obj/*.o -rm -f obj/*.o
-rm -f obj/nogui/*.o
-rm -f obj/test/*.o -rm -f obj/test/*.o
-rm -f obj/*.P -rm -f obj/*.P
-rm -f obj/nogui/*.P
-rm -f obj/test/*.P -rm -f obj/test/*.P

3
src/net.cpp

@ -938,7 +938,6 @@ void ThreadMapPort2(void* parg)
char port[6]; char port[6];
sprintf(port, "%d", GetListenPort()); sprintf(port, "%d", GetListenPort());
const char * rootdescurl = 0;
const char * multicastif = 0; const char * multicastif = 0;
const char * minissdpdpath = 0; const char * minissdpdpath = 0;
struct UPNPDev * devlist = 0; struct UPNPDev * devlist = 0;
@ -960,8 +959,6 @@ void ThreadMapPort2(void* parg)
r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
if (r == 1) if (r == 1)
{ {
char intClient[16];
char intPort[6];
string strDesc = "Bitcoin " + FormatFullVersion(); string strDesc = "Bitcoin " + FormatFullVersion();
#ifndef UPNPDISCOVER_SUCCESS #ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */ /* miniupnpc 1.5 */

4
src/net.h

@ -266,7 +266,9 @@ public:
// Make sure not to reuse time indexes to keep things in the same order // Make sure not to reuse time indexes to keep things in the same order
int64 nNow = (GetTime() - 1) * 1000000; int64 nNow = (GetTime() - 1) * 1000000;
static int64 nLastTime; 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 // Each retry is 2 minutes after the last
nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow); nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);

4
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) bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions, bool fAllowLookup)
{ {
vIP.clear(); vIP.clear();
struct addrinfo aiHint = {}; struct addrinfo aiHint;
memset(&aiHint, 0, sizeof(struct addrinfo));
aiHint.ai_socktype = SOCK_STREAM; aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP; aiHint.ai_protocol = IPPROTO_TCP;
#ifdef WIN32 #ifdef WIN32

3
src/serialize.h

@ -89,6 +89,7 @@ enum
const bool fRead = false; \ const bool fRead = false; \
unsigned int nSerSize = 0; \ unsigned int nSerSize = 0; \
ser_streamplaceholder s; \ ser_streamplaceholder s; \
assert(fGetSize||fWrite||fRead); /* suppress warning */ \
s.nType = nType; \ s.nType = nType; \
s.nVersion = nVersion; \ s.nVersion = nVersion; \
{statements} \ {statements} \
@ -102,6 +103,7 @@ enum
const bool fWrite = true; \ const bool fWrite = true; \
const bool fRead = false; \ const bool fRead = false; \
unsigned int nSerSize = 0; \ unsigned int nSerSize = 0; \
assert(fGetSize||fWrite||fRead); /* suppress warning */ \
{statements} \ {statements} \
} \ } \
template<typename Stream> \ template<typename Stream> \
@ -112,6 +114,7 @@ enum
const bool fWrite = false; \ const bool fWrite = false; \
const bool fRead = true; \ const bool fRead = true; \
unsigned int nSerSize = 0; \ unsigned int nSerSize = 0; \
assert(fGetSize||fWrite||fRead); /* suppress warning */ \
{statements} \ {statements} \
} }

Loading…
Cancel
Save