build: enable -Wextra by default
Change-Id: I1e6783fca6530741bf4b81dd13613a6b4235290a
Refs: #3293
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index f82fe10..9f15fcc 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -40,7 +40,7 @@
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
- conf.add_supported_cxxflags(extraFlags['LINKFLAGS'])
+ conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
conf.env.DEFINES += extraFlags['DEFINES']
@@ -83,15 +83,15 @@
class CompilerFlags(object):
def getGeneralFlags(self, conf):
- """Get dict {'CXXFLAGS':[...], LINKFLAGS:[...], DEFINES:[...]} that are always needed"""
+ """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
def getDebugFlags(self, conf):
- """Get tuple {CXXFLAGS, LINKFLAGS, DEFINES} that are needed in debug mode"""
+ """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
def getOptimizedFlags(self, conf):
- """Get tuple {CXXFLAGS, LINKFLAGS, DEFINES} that are needed in optimized mode"""
+ """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
class GccBasicFlags(CompilerFlags):
@@ -100,21 +100,25 @@
"""
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic',
- '-Wall',
- '-O0',
+ flags['CXXFLAGS'] += ['-O0',
'-g3',
+ '-pedantic',
+ '-Wall',
+ '-Wextra',
'-Werror',
+ '-Wno-unused-parameter',
'-Wno-error=maybe-uninitialized', # Bug #1615
]
return flags
def getOptimizedFlags(self, conf):
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic',
- '-Wall',
- '-O2',
+ flags['CXXFLAGS'] += ['-O2',
'-g',
+ '-pedantic',
+ '-Wall',
+ '-Wextra',
+ '-Wno-unused-parameter',
]
return flags
@@ -136,6 +140,9 @@
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (5, 1, 0):
+ flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
'-fdiagnostics-color', # gcc >= 4.9
]
@@ -143,6 +150,9 @@
def getOptimizedFlags(self, conf):
flags = super(GccFlags, self).getOptimizedFlags(conf)
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (5, 1, 0):
+ flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
return flags
diff --git a/tests/daemon/face/ethernet.t.cpp b/tests/daemon/face/ethernet.t.cpp
index a6faf06..4d6f053 100644
--- a/tests/daemon/face/ethernet.t.cpp
+++ b/tests/daemon/face/ethernet.t.cpp
@@ -201,22 +201,24 @@
face->onReceiveData.connect([&recDatas] (const Data& d) { recDatas.push_back(d); });
// check that packet data is not accessed if pcap didn't capture anything (caplen == 0)
- static const pcap_pkthdr header1{};
- face->processIncomingPacket(&header1, nullptr);
+ static const pcap_pkthdr zeroHeader{};
+ face->processIncomingPacket(&zeroHeader, nullptr);
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 0);
BOOST_CHECK_EQUAL(recInterests.size(), 0);
BOOST_CHECK_EQUAL(recDatas.size(), 0);
// runt frame (too short)
- static const pcap_pkthdr header2{{}, ethernet::HDR_LEN + 6};
+ pcap_pkthdr runtHeader{};
+ runtHeader.caplen = ethernet::HDR_LEN + 6;
static const uint8_t packet2[ethernet::HDR_LEN + 6]{};
- face->processIncomingPacket(&header2, packet2);
+ face->processIncomingPacket(&runtHeader, packet2);
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 0);
BOOST_CHECK_EQUAL(recInterests.size(), 0);
BOOST_CHECK_EQUAL(recDatas.size(), 0);
// valid frame, but TLV block has invalid length
- static const pcap_pkthdr header3{{}, ethernet::HDR_LEN + ethernet::MIN_DATA_LEN};
+ pcap_pkthdr validHeader{};
+ validHeader.caplen = ethernet::HDR_LEN + ethernet::MIN_DATA_LEN;
static const uint8_t packet3[ethernet::HDR_LEN + ethernet::MIN_DATA_LEN]{
0x01, 0x00, 0x5e, 0x00, 0x17, 0xaa, // destination address
0x02, 0x00, 0x00, 0x00, 0x00, 0x02, // source address
@@ -224,13 +226,12 @@
tlv::NdnlpData, // TLV type
0xfd, 0xff, 0xff // TLV length (invalid because greater than buffer size)
};
- face->processIncomingPacket(&header3, packet3);
+ face->processIncomingPacket(&validHeader, packet3);
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 0);
BOOST_CHECK_EQUAL(recInterests.size(), 0);
BOOST_CHECK_EQUAL(recDatas.size(), 0);
// valid frame, but TLV block has invalid type
- static const pcap_pkthdr header4{{}, ethernet::HDR_LEN + ethernet::MIN_DATA_LEN};
static const uint8_t packet4[ethernet::HDR_LEN + ethernet::MIN_DATA_LEN]{
0x01, 0x00, 0x5e, 0x00, 0x17, 0xaa, // destination address
0x02, 0x00, 0x00, 0x00, 0x00, 0x02, // source address
@@ -238,13 +239,12 @@
0x00, // TLV type (invalid)
0x00 // TLV length
};
- face->processIncomingPacket(&header4, packet4);
+ face->processIncomingPacket(&validHeader, packet4);
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 2);
BOOST_CHECK_EQUAL(recInterests.size(), 0);
BOOST_CHECK_EQUAL(recDatas.size(), 0);
// valid frame and valid NDNLP header, but invalid payload
- static const pcap_pkthdr header5{{}, ethernet::HDR_LEN + ethernet::MIN_DATA_LEN};
static const uint8_t packet5[ethernet::HDR_LEN + ethernet::MIN_DATA_LEN]{
0x01, 0x00, 0x5e, 0x00, 0x17, 0xaa, // destination address
0x02, 0x00, 0x00, 0x00, 0x00, 0x02, // source address
@@ -256,13 +256,12 @@
0x00, // NDN TLV type (invalid)
0x00 // NDN TLV length
};
- face->processIncomingPacket(&header5, packet5);
+ face->processIncomingPacket(&validHeader, packet5);
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 18);
BOOST_CHECK_EQUAL(recInterests.size(), 0);
BOOST_CHECK_EQUAL(recDatas.size(), 0);
// valid frame, valid NDNLP header, and valid NDN (interest) packet
- static const pcap_pkthdr header6{{}, ethernet::HDR_LEN + ethernet::MIN_DATA_LEN};
static const uint8_t packet6[ethernet::HDR_LEN + ethernet::MIN_DATA_LEN]{
0x01, 0x00, 0x5e, 0x00, 0x17, 0xaa, // destination address
0x02, 0x00, 0x00, 0x00, 0x00, 0x02, // source address
@@ -276,7 +275,7 @@
0x03, 0x66, 0x6f, 0x6f, 0x0a, 0x04,
0x03, 0xef, 0xe9, 0x7c
};
- face->processIncomingPacket(&header6, packet6);
+ face->processIncomingPacket(&validHeader, packet6);
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 56);
BOOST_CHECK_EQUAL(recInterests.size(), 1);
BOOST_CHECK_EQUAL(recDatas.size(), 0);
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index 26c29c1..75c5a67 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -94,7 +94,7 @@
shared_ptr<Face> outFace,
bool wantNewNonce)
{
- SendInterestArgs args{pitEntry, outFace->getId()};
+ SendInterestArgs args{pitEntry, outFace->getId(), wantNewNonce};
sendInterestHistory.push_back(args);
pitEntry->insertOrUpdateOutRecord(outFace, pitEntry->getInterest());
afterAction();