summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2023-12-04 10:18:55 +0100
committerRazvan Becheriu <razvan@isc.org>2024-01-22 16:33:26 +0100
commit1eb9c75f3fd50c2da9fbef7e34f4638fa92d34d1 (patch)
treeb5bc4921c7557913251c7f70f068ab67682a522d
parent[#3119] static cast time_t to uint32 (diff)
downloadkea-1eb9c75f3fd50c2da9fbef7e34f4638fa92d34d1.tar.xz
kea-1eb9c75f3fd50c2da9fbef7e34f4638fa92d34d1.zip
[#3119] Fixed some coverity reported defects
-rw-r--r--src/bin/dhcp6/dhcp6_srv.cc6
-rw-r--r--src/hooks/dhcp/flex_option/flex_option.h4
-rw-r--r--src/lib/cc/data.cc6
-rw-r--r--src/lib/dhcpsrv/cfg_option.cc4
-rw-r--r--src/lib/dhcpsrv/parsers/client_class_def_parser.cc2
-rw-r--r--src/lib/dhcpsrv/srv_config.cc2
-rw-r--r--src/lib/dhcpsrv/subnet.cc2
-rw-r--r--src/lib/process/redact_config.cc2
-rw-r--r--src/lib/stats/context.cc4
9 files changed, 16 insertions, 16 deletions
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 60324d0c3f..6024cdd2df 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1426,7 +1426,7 @@ Dhcpv6Srv::buildCfgOptionList(const Pkt6Ptr& question,
// Secondly, pool specific options. Pools are defined within a subnet, so
// if there is no subnet, there is nothing to do.
if (ctx.subnet_) {
- for (auto resource : ctx.allocated_resources_) {
+ for (const auto& resource : ctx.allocated_resources_) {
PoolPtr pool =
ctx.subnet_->getPool(resource.getPrefixLength() == 128 ?
Lease::TYPE_NA : Lease::TYPE_PD,
@@ -4211,7 +4211,7 @@ Dhcpv6Srv::processDhcp4Query(const Pkt6Ptr& dhcp4_query) {
void Dhcpv6Srv::classifyByVendor(const Pkt6Ptr& pkt) {
OptionVendorClassPtr vclass;
- for (auto opt : pkt->getOptions(D6O_VENDOR_CLASS)) {
+ for (const auto& opt : pkt->getOptions(D6O_VENDOR_CLASS)) {
vclass = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
if (!vclass || vclass->getTuplesNum() == 0) {
continue;
@@ -4333,7 +4333,7 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
}
// And finish by pools
- for (auto resource : ctx.allocated_resources_) {
+ for (const auto& resource : ctx.allocated_resources_) {
PoolPtr pool =
ctx.subnet_->getPool(resource.getPrefixLength() == 128 ?
Lease::TYPE_NA : Lease::TYPE_PD,
diff --git a/src/hooks/dhcp/flex_option/flex_option.h b/src/hooks/dhcp/flex_option/flex_option.h
index bda8ca186e..e26b437ed9 100644
--- a/src/hooks/dhcp/flex_option/flex_option.h
+++ b/src/hooks/dhcp/flex_option/flex_option.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2022 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2019-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -375,7 +375,7 @@ public:
}
}
for (auto pair : getSubOptionConfigMap()) {
- for (auto sub_pair : pair.second) {
+ for (const auto& sub_pair : pair.second) {
const SubOptionConfigPtr& sub_cfg = sub_pair.second;
uint16_t sub_code = sub_cfg->getCode();
uint16_t opt_code = sub_cfg->getContainerCode();
diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc
index 12d59b44ea..9b13bcea5c 100644
--- a/src/lib/cc/data.cc
+++ b/src/lib/cc/data.cc
@@ -1178,7 +1178,7 @@ removeIdentical(ConstElementPtr a, ConstElementPtr b) {
isc_throw(TypeError, "Non-map Elements passed to removeIdentical");
}
- for (auto kv : a->mapValue()) {
+ for (const auto& kv : a->mapValue()) {
auto key = kv.first;
if (!b->contains(key) ||
!a->get(key)->equals(*b->get(key))) {
@@ -1196,7 +1196,7 @@ merge(ElementPtr element, ConstElementPtr other) {
isc_throw(TypeError, "merge arguments not MapElements");
}
- for (auto kv : other->mapValue()) {
+ for (const auto& kv : other->mapValue()) {
auto key = kv.first;
auto value = kv.second;
if (value && value->getType() != Element::null) {
@@ -1517,7 +1517,7 @@ isEquivalent0(ConstElementPtr a, ConstElementPtr b, unsigned level) {
return (false);
}
// iterate on the first map
- for (auto kv : a->mapValue()) {
+ for (const auto& kv : a->mapValue()) {
// get the b value for the given keyword and recurse
ConstElementPtr item = b->get(kv.first);
if (!item || !isEquivalent0(kv.second, item, level - 1)) {
diff --git a/src/lib/dhcpsrv/cfg_option.cc b/src/lib/dhcpsrv/cfg_option.cc
index 5999b9079f..9a241dfa9f 100644
--- a/src/lib/dhcpsrv/cfg_option.cc
+++ b/src/lib/dhcpsrv/cfg_option.cc
@@ -162,7 +162,7 @@ CfgOption::createOptions(CfgOptionDefPtr cfg_def) {
// Iterate over all the option descriptors in
// all the spaces and instantiate the options
// based on the given definitions.
- for (auto space : getOptionSpaceNames()) {
+ for (const auto& space : getOptionSpaceNames()) {
for (auto opt_desc : *(getAll(space))) {
if (createDescriptorOption(cfg_def, space, opt_desc)) {
// Option was recreated, let's replace the descriptor.
@@ -372,7 +372,7 @@ CfgOption::del(const std::string& option_space, const uint16_t option_code) {
(option_space != DHCP6_OPTION_SPACE)) {
// For each option space name iterate over the existing options.
auto option_space_names = getOptionSpaceNames();
- for (auto option_space_from_list : option_space_names) {
+ for (const auto& option_space_from_list : option_space_names) {
// Get all options within the particular option space.
auto options_in_space = getAll(option_space_from_list);
for (auto option_it = options_in_space->begin();
diff --git a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc
index 291632bae0..a62af4d9f7 100644
--- a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc
+++ b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc
@@ -251,7 +251,7 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
}
// Sanity checks on built-in classes
- for (auto bn : builtinNames) {
+ for (const auto& bn : builtinNames) {
if (name == bn) {
if (required) {
isc_throw(DhcpConfigError, "built-in class '" << name
diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc
index 66cb9b2511..750b0797c9 100644
--- a/src/lib/dhcpsrv/srv_config.cc
+++ b/src/lib/dhcpsrv/srv_config.cc
@@ -333,7 +333,7 @@ SrvConfig::applyDefaultsConfiguredGlobals(const SimpleDefaults& defaults) {
const Element::Position pos("<default-value>", 0, 0);
// Let's go over all parameters we have defaults for.
- for (auto def_value : defaults) {
+ for (const auto& def_value : defaults) {
// Try if such a parameter is there. If it is, let's
// skip it, because user knows best *cough*.
diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc
index 2e480d474b..d0a380d7a2 100644
--- a/src/lib/dhcpsrv/subnet.cc
+++ b/src/lib/dhcpsrv/subnet.cc
@@ -442,7 +442,7 @@ const PoolPtr Subnet::getPool(Lease::Type type, const isc::asiolink::IOAddress&
void
Subnet::initAllocatorsAfterConfigure() {
- for (auto allocator : allocators_) {
+ for (const auto& allocator : allocators_) {
allocator.second->initAfterConfigure();
}
}
diff --git a/src/lib/process/redact_config.cc b/src/lib/process/redact_config.cc
index 16bba0f3ce..686620e324 100644
--- a/src/lib/process/redact_config.cc
+++ b/src/lib/process/redact_config.cc
@@ -46,7 +46,7 @@ redact(ElementPtrType const& element, list<string> json_path) {
if (next_key == "*" || json_path.empty()) {
// Then iterate through all the children.
result = Element::createMap();
- for (auto kv : element->mapValue()) {
+ for (const auto& kv : element->mapValue()) {
std::string const& key(kv.first);
ConstElementPtr const& value(kv.second);
diff --git a/src/lib/stats/context.cc b/src/lib/stats/context.cc
index 697b3de7e3..3675df9fbe 100644
--- a/src/lib/stats/context.cc
+++ b/src/lib/stats/context.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -80,7 +80,7 @@ StatContext::getAll() const {
void
StatContext::setMaxSampleCountAll(uint32_t max_samples) {
// Let's iterate over all stored statistics...
- for (auto s : stats_) {
+ for (const auto& s : stats_) {
// ... and set count limit for each statistic.
s.second->setMaxSampleCount(max_samples);
}