Commit fc951496 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Merge #2726

Enable more checking in cppcheck and fix the warnings produced by that.
parents 2419d183 430c0c7e
......@@ -110,7 +110,8 @@ report-coverage: report-cpp-coverage report-python-coverage
# for static C++ check using cppcheck (when available)
cppcheck:
cppcheck --enable=all --suppressions src/cppcheck-suppress.lst --inline-suppr \
cppcheck -I./src/lib -I./src/bin --enable=all --suppressions \
src/cppcheck-suppress.lst --inline-suppr \
--quiet --error-exitcode=1 \
--template '{file}:{line}: check_fail: {message} ({severity},{id})' \
src
......
......@@ -388,7 +388,8 @@ private:
};
AuthSrv::AuthSrv(isc::xfr::AbstractXfroutClient& xfrout_client,
isc::util::io::BaseSocketSessionForwarder& ddns_forwarder)
isc::util::io::BaseSocketSessionForwarder& ddns_forwarder) :
dnss_(NULL)
{
impl_ = new AuthSrvImpl(xfrout_client, ddns_forwarder);
checkin_ = new ConfigChecker(this);
......
......@@ -126,7 +126,8 @@ bool
Dhcpv4Srv::run() {
while (!shutdown_) {
/// @todo: calculate actual timeout once we have lease database
int timeout = 1000;
//cppcheck-suppress variableScope This is temporary anyway
const int timeout = 1000;
// client's message and server's response
Pkt4Ptr query;
......
......@@ -134,7 +134,8 @@ bool Dhcpv6Srv::run() {
/// For now, we are just calling select for 1000 seconds. There
/// were some issues reported on some systems when calling select()
/// with too large values. Unfortunately, I don't recall the details.
int timeout = 1000;
//cppcheck-suppress variableScope This is temporary anyway
const int timeout = 1000;
// client's message and server's response
Pkt6Ptr query;
......
......@@ -410,10 +410,9 @@ void IOFetch::logIOFailure(asio::error_code ec) {
(data_->origin == ASIODNS_READ_DATA) ||
(data_->origin == ASIODNS_UNKNOWN_ORIGIN));
static const char* PROTOCOL[2] = {"TCP", "UDP"};
LOG_ERROR(logger, data_->origin).arg(ec.value()).
arg((data_->remote_snd->getProtocol() == IPPROTO_TCP) ?
PROTOCOL[0] : PROTOCOL[1]).
"TCP" : "UDP").
arg(data_->remote_snd->getAddress().toText()).
arg(data_->remote_snd->getPort());
}
......
......@@ -693,10 +693,9 @@ NullElement::toJSON(std::ostream& ss) const {
void
StringElement::toJSON(std::ostream& ss) const {
ss << "\"";
char c;
const std::string& str = stringValue();
for (size_t i = 0; i < str.size(); ++i) {
c = str[i];
const char c = str[i];
// Escape characters as defined in JSON spec
// Note that we do not escape forward slash; this
// is allowed, but not mandatory.
......
......@@ -705,7 +705,13 @@ public:
// XXX: meaningless initial values:
last_comparison_(0, 0,
isc::dns::NameComparisonResult::EQUAL)
{}
{
// To silence cppcheck. We don't really use the values before
// initialization, but this is cleaner anyway.
for (size_t i = 0; i < RBT_MAX_LEVEL; ++i) {
nodes_[i] = NULL;
}
}
/// \brief Copy constructor.
///
......@@ -828,6 +834,7 @@ private:
/// the top node
///
/// \exception None
// cppcheck-suppress unusedPrivateFunction (false positive, it is used)
void pop() {
assert(!isEmpty());
--level_count_;
......@@ -840,6 +847,7 @@ private:
/// otherwise the node should be the root node of DomainTree.
///
/// \exception None
// cppcheck-suppress unusedPrivateFunction (false positive, it is used)
void push(const DomainTreeNode<T>* node) {
assert(level_count_ < RBT_MAX_LEVEL);
nodes_[level_count_++] = node;
......
......@@ -1137,6 +1137,9 @@ const char* TEST_NSEC3_RECORDS[][5] = {
};
DatabaseClientTest::DatabaseClientTest() :
// We need to initialize to something, and not being mock is safer
// until we know for sure.
is_mock_(false),
zname_("example.org"), qname_("www.example.org"),
qclass_(dns::RRClass::IN()),
qtype_(dns::RRType::A()),
......
......@@ -39,6 +39,8 @@ void
pathtestHelper(const std::string& file, const std::string& expected_error) {
std::string error;
try {
// cppcheck-suppress unusedScopedObject We just check if it throws
// to create, not use it. That's OK.
DataSourceClientContainer(file, ElementPtr());
} catch (const DataSourceLibraryError& dsle) {
error = dsle.what();
......
......@@ -310,6 +310,7 @@ private:
///
/// @throw isc::dhcp::InvalidDataType if the type is invalid.
template<typename T>
// cppcheck-suppress unusedPrivateFunction
void checkDataType(const uint32_t index) const;
/// @brief Check if data field index is valid.
......
......@@ -227,14 +227,6 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
return (optionFactory(u, type, buf.begin(), buf.end()));
}
void
OptionDefinition::sanityCheckUniverse(const Option::Universe expected_universe,
const Option::Universe actual_universe) {
if (expected_universe != actual_universe) {
isc_throw(isc::BadValue, "invalid universe specified for the option");
}
}
void
OptionDefinition::validate() const {
......
......@@ -501,15 +501,6 @@ private:
void writeToBuffer(const std::string& value, const OptionDataType type,
OptionBuffer& buf) const;
/// @brief Sanity check universe value.
///
/// @param expected_universe expected universe value.
/// @param actual_universe actual universe value.
///
/// @throw isc::BadValue if expected universe and actual universe don't match.
static inline void sanityCheckUniverse(const Option::Universe expected_universe,
const Option::Universe actual_universe);
/// Option name.
std::string name_;
/// Option code.
......
......@@ -22,6 +22,8 @@
#include <stdint.h>
#include <boost/noncopyable.hpp>
namespace isc {
namespace dns {
namespace master_lexer_internal {
......@@ -303,7 +305,7 @@ private:
/// implementation of the exception handling). For these reasons, some of
/// this class does not throw for an error that would be reported as an
/// exception in other classes.
class MasterLexer {
class MasterLexer : public boost::noncopyable {
friend class master_lexer_internal::State;
public:
/// \brief Exception thrown when we fail to read from the input
......
......@@ -56,9 +56,8 @@ PyObject* po_DNSMessageBADVERS;
int
readDataFromSequence(uint8_t *data, size_t len, PyObject* sequence) {
PyObject* el = NULL;
for (size_t i = 0; i < len; i++) {
el = PySequence_GetItem(sequence, i);
PyObject *el = PySequence_GetItem(sequence, i);
if (!el) {
PyErr_SetString(PyExc_TypeError,
"sequence too short");
......
......@@ -310,6 +310,9 @@ Generic::Generic(const Generic& source) :
{}
Generic&
// Our check is better than the usual if (this == &source),
// but cppcheck doesn't recognize it.
// cppcheck-suppress operatorEqToSelf
Generic::operator=(const Generic& source) {
if (impl_ == source.impl_) {
return (*this);
......
......@@ -338,7 +338,7 @@ TSIG::TSIG(const TSIG& source) : Rdata(), impl_(new TSIGImpl(*source.impl_))
TSIG&
TSIG::operator=(const TSIG& source) {
if (impl_ == source.impl_) {
if (this == &source) {
return (*this);
}
......
......@@ -188,12 +188,12 @@ public:
/// \brief The copy constructor.
///
/// Trivial for now, we could've used the default one.
DSLikeImpl(const DSLikeImpl& source) {
digest_ = source.digest_;
tag_ = source.tag_;
algorithm_ = source.algorithm_;
digest_type_ = source.digest_type_;
}
DSLikeImpl(const DSLikeImpl& source) :
tag_(source.tag_),
algorithm_(source.algorithm_),
digest_type_(source.digest_type_),
digest_(source.digest_)
{}
/// \brief Convert the DS-like data to a string.
///
......
......@@ -62,7 +62,7 @@ DLV::DLV(const DLV& source) :
/// PIMPL-induced logic
DLV&
DLV::operator=(const DLV& source) {
if (impl_ == source.impl_) {
if (this == &source) {
return (*this);
}
......
......@@ -212,7 +212,7 @@ DNSKEY::DNSKEY(const DNSKEY& source) :
DNSKEY&
DNSKEY::operator=(const DNSKEY& source) {
if (impl_ == source.impl_) {
if (this == &source) {
return (*this);
}
......
......@@ -50,7 +50,7 @@ DS::DS(const DS& source) :
DS&
DS::operator=(const DS& source) {
if (impl_ == source.impl_) {
if (this == &source) {
return (*this);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment