build: restore checking of compiler flags
Accidentally removed in commit bb058c0466076c2f72f52f7778ae0082ea45e326
Fix resulting warnings
Change-Id: I619276a520497e3b94298902b180fdbbd11efd2c
diff --git a/src/storage/index.hpp b/src/storage/index.hpp
index 51d51b2..d60bd37 100644
--- a/src/storage/index.hpp
+++ b/src/storage/index.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -20,7 +20,8 @@
#ifndef REPO_STORAGE_INDEX_HPP
#define REPO_STORAGE_INDEX_HPP
-#include "common.hpp"
+#include "../common.hpp"
+
#include <set>
namespace repo {
@@ -52,13 +53,10 @@
};
public:
-
/**
* @brief used by set to construct node
*/
- Entry()
- {
- };
+ Entry() = default;
/**
* @brief construct Entry by data and id number
@@ -143,7 +141,6 @@
};
private:
-
typedef std::set<Entry> IndexContainer;
public:
diff --git a/src/storage/storage.hpp b/src/storage/storage.hpp
index bf75306..e1cb537 100755
--- a/src/storage/storage.hpp
+++ b/src/storage/storage.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -19,9 +19,7 @@
#ifndef REPO_STORAGE_STORAGE_HPP
#define REPO_STORAGE_STORAGE_HPP
-#include <string>
-#include <iostream>
-#include <stdlib.h>
+
#include "../common.hpp"
namespace repo {
@@ -42,7 +40,6 @@
}
};
-public:
class ItemMeta
{
public:
@@ -51,12 +48,9 @@
ndn::ConstBufferPtr keyLocatorHash;
};
-public :
-
+public:
virtual
- ~Storage()
- {
- };
+ ~Storage() = default;
/**
* @brief put the data into database
@@ -91,9 +85,8 @@
*/
virtual void
fullEnumerate(const std::function<void(const Storage::ItemMeta)>& f) = 0;
-
};
} // namespace repo
-#endif // REPO_STORAGE_Storage_HPP
+#endif // REPO_STORAGE_STORAGE_HPP
diff --git a/tools/ndngetfile.cpp b/tools/ndngetfile.cpp
index 125eab0..dbc5b5d 100644
--- a/tools/ndngetfile.cpp
+++ b/tools/ndngetfile.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2018, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -42,22 +42,17 @@
{
Interest interest(name);
interest.setInterestLifetime(m_interestLifetime);
- //std::cout<<"interest name = "<<interest.getName()<<std::endl;
- if (m_hasVersion)
- {
- interest.setMustBeFresh(m_mustBeFresh);
- }
- else
- {
- interest.setMustBeFresh(true);
- interest.setChildSelector(1);
- }
+ if (m_hasVersion) {
+ interest.setMustBeFresh(m_mustBeFresh);
+ }
+ else {
+ interest.setMustBeFresh(true);
+ interest.setChildSelector(1);
+ }
m_face.expressInterest(interest,
- m_hasVersion ?
- bind(&Consumer::onVersionedData, this, _1, _2)
- :
- bind(&Consumer::onUnversionedData, this, _1, _2),
+ m_hasVersion ? bind(&Consumer::onVersionedData, this, _1, _2)
+ : bind(&Consumer::onUnversionedData, this, _1, _2),
bind(&Consumer::onTimeout, this, _1), // Nack
bind(&Consumer::onTimeout, this, _1));
}
@@ -156,8 +151,7 @@
const Block& content = data.getContent();
m_os.write(reinterpret_cast<const char*>(content.value()), content.value_size());
m_totalSize += content.value_size();
- if (m_verbose)
- {
+ if (m_verbose) {
std::cerr << "LOG: received data = " << data.getName() << std::endl;
}
if (m_isFinished || m_isSingle) {
@@ -171,13 +165,13 @@
Consumer::fetchNextData(const Name& name, const Data& data)
{
uint64_t segment = name[-1].toSegment();
- BOOST_ASSERT(segment == (m_nextSegment - 1));
+ BOOST_VERIFY(segment == (m_nextSegment - 1));
+
const ndn::name::Component& finalBlockId = data.getMetaInfo().getFinalBlockId();
if (finalBlockId == name[-1]) {
m_isFinished = true;
}
- else
- {
+ else {
// Reset retry counter
m_retryCount = 0;
if (m_hasVersion)
@@ -190,24 +184,19 @@
void
Consumer::onTimeout(const Interest& interest)
{
- if (m_retryCount++ < MAX_RETRY)
- {
- // Retransmit the interest
- fetchData(interest.getName());
- if (m_verbose)
- {
- std::cerr << "TIMEOUT: retransmit interest for " << interest.getName() << std::endl;
- }
- }
- else
- {
- std::cerr << "TIMEOUT: last interest sent for segment #" << (m_nextSegment - 1) << std::endl;
- std::cerr << "TIMEOUT: abort fetching after " << MAX_RETRY
- << " times of retry" << std::endl;
- }
+ if (m_retryCount++ < MAX_RETRY) {
+ // Retransmit the interest
+ fetchData(interest.getName());
+ if (m_verbose)
+ std::cerr << "TIMEOUT: retransmit interest for " << interest.getName() << std::endl;
+ }
+ else {
+ std::cerr << "TIMEOUT: last interest sent for segment #" << (m_nextSegment - 1) << std::endl;
+ std::cerr << "TIMEOUT: abort fetching after " << MAX_RETRY
+ << " times of retry" << std::endl;
+ }
}
-
int
usage(const std::string& filename)
{
@@ -224,101 +213,85 @@
return 1;
}
-
int
main(int argc, char** argv)
{
std::string name;
- const char* outputFile = 0;
+ const char* outputFile = nullptr;
bool verbose = false, versioned = false, single = false;
int interestLifetime = 4000; // in milliseconds
int timeout = 0; // in milliseconds
int opt;
- while ((opt = getopt(argc, argv, "vsul:w:o:")) != -1)
- {
- switch (opt) {
- case 'v':
- verbose = true;
- break;
- case 's':
- single = true;
- break;
- case 'u':
- versioned = true;
- break;
- case 'l':
- try
- {
- interestLifetime = boost::lexical_cast<int>(optarg);
- }
- catch (const boost::bad_lexical_cast&)
- {
- std::cerr << "ERROR: -l option should be an integer." << std::endl;
- return 1;
- }
- interestLifetime = std::max(interestLifetime, 0);
- break;
- case 'w':
- try
- {
- timeout = boost::lexical_cast<int>(optarg);
- }
- catch (const boost::bad_lexical_cast&)
- {
- std::cerr << "ERROR: -w option should be an integer." << std::endl;
- return 1;
- }
- timeout = std::max(timeout, 0);
- break;
- case 'o':
- outputFile = optarg;
- break;
- default:
- return usage(argv[0]);
+ while ((opt = getopt(argc, argv, "vsul:w:o:")) != -1) {
+ switch (opt) {
+ case 'v':
+ verbose = true;
+ break;
+ case 's':
+ single = true;
+ break;
+ case 'u':
+ versioned = true;
+ break;
+ case 'l':
+ try {
+ interestLifetime = boost::lexical_cast<int>(optarg);
}
- }
-
- if (optind < argc)
- {
- name = argv[optind];
- }
-
- if (name.empty())
- {
+ catch (const boost::bad_lexical_cast&) {
+ std::cerr << "ERROR: -l option should be an integer." << std::endl;
+ return 1;
+ }
+ interestLifetime = std::max(interestLifetime, 0);
+ break;
+ case 'w':
+ try {
+ timeout = boost::lexical_cast<int>(optarg);
+ }
+ catch (const boost::bad_lexical_cast&) {
+ std::cerr << "ERROR: -w option should be an integer." << std::endl;
+ return 1;
+ }
+ timeout = std::max(timeout, 0);
+ break;
+ case 'o':
+ outputFile = optarg;
+ break;
+ default:
return usage(argv[0]);
}
+ }
+
+ if (optind < argc)
+ name = argv[optind];
+
+ if (name.empty())
+ return usage(argv[0]);
std::streambuf* buf;
std::ofstream of;
- if (outputFile != 0)
- {
- of.open(outputFile, std::ios::out | std::ios::binary | std::ios::trunc);
- if (!of || !of.is_open()) {
- std::cerr << "ERROR: cannot open " << outputFile << std::endl;
- return 1;
- }
- buf = of.rdbuf();
+ if (outputFile != nullptr) {
+ of.open(outputFile, std::ios::out | std::ios::binary | std::ios::trunc);
+ if (!of || !of.is_open()) {
+ std::cerr << "ERROR: cannot open " << outputFile << std::endl;
+ return 1;
}
- else
- {
- buf = std::cout.rdbuf();
- }
+ buf = of.rdbuf();
+ }
+ else {
+ buf = std::cout.rdbuf();
+ }
std::ostream os(buf);
+ Consumer consumer(name, os, verbose, versioned, single, interestLifetime, timeout);
- Consumer consumer(name, os, verbose, versioned, single,
- interestLifetime, timeout);
-
- try
- {
- consumer.run();
- }
- catch (const std::exception& e)
- {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
+ try {
+ consumer.run();
+ }
+ catch (const std::exception& e) {
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ }
return 0;
}
diff --git a/wscript b/wscript
index a4b84fe..48f296a 100644
--- a/wscript
+++ b/wscript
@@ -7,8 +7,9 @@
import os
def options(opt):
- opt.load('compiler_c compiler_cxx gnu_dirs')
- opt.load('boost default-compiler-flags doxygen sqlite3 coverage sanitizers',
+ opt.load(['compiler_cxx', 'gnu_dirs'])
+ opt.load(['default-compiler-flags', 'coverage', 'sanitizers', 'boost',
+ 'sqlite3', 'doxygen'],
tooldir=['.waf-tools'])
ropt = opt.add_option_group('ndn-repo-ng Options')
@@ -21,7 +22,8 @@
help='''Do not build tools''')
def configure(conf):
- conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags sqlite3")
+ conf.load(['compiler_cxx', 'gnu_dirs',
+ 'default-compiler-flags', 'boost', 'sqlite3'])
if 'PKG_CONFIG_PATH' not in os.environ:
os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
@@ -45,9 +47,10 @@
except:
pass
+ conf.check_compiler_flags()
+
# Loading "late" to prevent tests from being compiled with profiling flags
conf.load('coverage')
-
conf.load('sanitizers')
conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR'])