2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 22:15:23 +00:00

[#3119] Fixed some coverity reported defects

This commit is contained in:
Francis Dupont
2023-12-04 10:18:55 +01:00
committed by Razvan Becheriu
parent 78acb9cec0
commit 1eb9c75f3f
9 changed files with 16 additions and 16 deletions

View File

@@ -1426,7 +1426,7 @@ Dhcpv6Srv::buildCfgOptionList(const Pkt6Ptr& question,
// Secondly, pool specific options. Pools are defined within a subnet, so // Secondly, pool specific options. Pools are defined within a subnet, so
// if there is no subnet, there is nothing to do. // if there is no subnet, there is nothing to do.
if (ctx.subnet_) { if (ctx.subnet_) {
for (auto resource : ctx.allocated_resources_) { for (const auto& resource : ctx.allocated_resources_) {
PoolPtr pool = PoolPtr pool =
ctx.subnet_->getPool(resource.getPrefixLength() == 128 ? ctx.subnet_->getPool(resource.getPrefixLength() == 128 ?
Lease::TYPE_NA : Lease::TYPE_PD, Lease::TYPE_NA : Lease::TYPE_PD,
@@ -4211,7 +4211,7 @@ Dhcpv6Srv::processDhcp4Query(const Pkt6Ptr& dhcp4_query) {
void Dhcpv6Srv::classifyByVendor(const Pkt6Ptr& pkt) { void Dhcpv6Srv::classifyByVendor(const Pkt6Ptr& pkt) {
OptionVendorClassPtr vclass; 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); vclass = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second);
if (!vclass || vclass->getTuplesNum() == 0) { if (!vclass || vclass->getTuplesNum() == 0) {
continue; continue;
@@ -4333,7 +4333,7 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
} }
// And finish by pools // And finish by pools
for (auto resource : ctx.allocated_resources_) { for (const auto& resource : ctx.allocated_resources_) {
PoolPtr pool = PoolPtr pool =
ctx.subnet_->getPool(resource.getPrefixLength() == 128 ? ctx.subnet_->getPool(resource.getPrefixLength() == 128 ?
Lease::TYPE_NA : Lease::TYPE_PD, Lease::TYPE_NA : Lease::TYPE_PD,

View File

@@ -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 // 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 // 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 pair : getSubOptionConfigMap()) {
for (auto sub_pair : pair.second) { for (const auto& sub_pair : pair.second) {
const SubOptionConfigPtr& sub_cfg = sub_pair.second; const SubOptionConfigPtr& sub_cfg = sub_pair.second;
uint16_t sub_code = sub_cfg->getCode(); uint16_t sub_code = sub_cfg->getCode();
uint16_t opt_code = sub_cfg->getContainerCode(); uint16_t opt_code = sub_cfg->getContainerCode();

View File

@@ -1178,7 +1178,7 @@ removeIdentical(ConstElementPtr a, ConstElementPtr b) {
isc_throw(TypeError, "Non-map Elements passed to removeIdentical"); isc_throw(TypeError, "Non-map Elements passed to removeIdentical");
} }
for (auto kv : a->mapValue()) { for (const auto& kv : a->mapValue()) {
auto key = kv.first; auto key = kv.first;
if (!b->contains(key) || if (!b->contains(key) ||
!a->get(key)->equals(*b->get(key))) { !a->get(key)->equals(*b->get(key))) {
@@ -1196,7 +1196,7 @@ merge(ElementPtr element, ConstElementPtr other) {
isc_throw(TypeError, "merge arguments not MapElements"); isc_throw(TypeError, "merge arguments not MapElements");
} }
for (auto kv : other->mapValue()) { for (const auto& kv : other->mapValue()) {
auto key = kv.first; auto key = kv.first;
auto value = kv.second; auto value = kv.second;
if (value && value->getType() != Element::null) { if (value && value->getType() != Element::null) {
@@ -1517,7 +1517,7 @@ isEquivalent0(ConstElementPtr a, ConstElementPtr b, unsigned level) {
return (false); return (false);
} }
// iterate on the first map // 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 // get the b value for the given keyword and recurse
ConstElementPtr item = b->get(kv.first); ConstElementPtr item = b->get(kv.first);
if (!item || !isEquivalent0(kv.second, item, level - 1)) { if (!item || !isEquivalent0(kv.second, item, level - 1)) {

View File

@@ -162,7 +162,7 @@ CfgOption::createOptions(CfgOptionDefPtr cfg_def) {
// Iterate over all the option descriptors in // Iterate over all the option descriptors in
// all the spaces and instantiate the options // all the spaces and instantiate the options
// based on the given definitions. // based on the given definitions.
for (auto space : getOptionSpaceNames()) { for (const auto& space : getOptionSpaceNames()) {
for (auto opt_desc : *(getAll(space))) { for (auto opt_desc : *(getAll(space))) {
if (createDescriptorOption(cfg_def, space, opt_desc)) { if (createDescriptorOption(cfg_def, space, opt_desc)) {
// Option was recreated, let's replace the descriptor. // 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)) { (option_space != DHCP6_OPTION_SPACE)) {
// For each option space name iterate over the existing options. // For each option space name iterate over the existing options.
auto option_space_names = getOptionSpaceNames(); 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. // Get all options within the particular option space.
auto options_in_space = getAll(option_space_from_list); auto options_in_space = getAll(option_space_from_list);
for (auto option_it = options_in_space->begin(); for (auto option_it = options_in_space->begin();

View File

@@ -251,7 +251,7 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
} }
// Sanity checks on built-in classes // Sanity checks on built-in classes
for (auto bn : builtinNames) { for (const auto& bn : builtinNames) {
if (name == bn) { if (name == bn) {
if (required) { if (required) {
isc_throw(DhcpConfigError, "built-in class '" << name isc_throw(DhcpConfigError, "built-in class '" << name

View File

@@ -333,7 +333,7 @@ SrvConfig::applyDefaultsConfiguredGlobals(const SimpleDefaults& defaults) {
const Element::Position pos("<default-value>", 0, 0); const Element::Position pos("<default-value>", 0, 0);
// Let's go over all parameters we have defaults for. // 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 // Try if such a parameter is there. If it is, let's
// skip it, because user knows best *cough*. // skip it, because user knows best *cough*.

View File

@@ -442,7 +442,7 @@ const PoolPtr Subnet::getPool(Lease::Type type, const isc::asiolink::IOAddress&
void void
Subnet::initAllocatorsAfterConfigure() { Subnet::initAllocatorsAfterConfigure() {
for (auto allocator : allocators_) { for (const auto& allocator : allocators_) {
allocator.second->initAfterConfigure(); allocator.second->initAfterConfigure();
} }
} }

View File

@@ -46,7 +46,7 @@ redact(ElementPtrType const& element, list<string> json_path) {
if (next_key == "*" || json_path.empty()) { if (next_key == "*" || json_path.empty()) {
// Then iterate through all the children. // Then iterate through all the children.
result = Element::createMap(); result = Element::createMap();
for (auto kv : element->mapValue()) { for (const auto& kv : element->mapValue()) {
std::string const& key(kv.first); std::string const& key(kv.first);
ConstElementPtr const& value(kv.second); ConstElementPtr const& value(kv.second);

View File

@@ -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 // 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 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -80,7 +80,7 @@ StatContext::getAll() const {
void void
StatContext::setMaxSampleCountAll(uint32_t max_samples) { StatContext::setMaxSampleCountAll(uint32_t max_samples) {
// Let's iterate over all stored statistics... // Let's iterate over all stored statistics...
for (auto s : stats_) { for (const auto& s : stats_) {
// ... and set count limit for each statistic. // ... and set count limit for each statistic.
s.second->setMaxSampleCount(max_samples); s.second->setMaxSampleCount(max_samples);
} }