2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#3785] Checkpoint

This commit is contained in:
Francis Dupont 2025-03-11 16:44:24 +01:00
parent 31d33d62cf
commit 6fbf286f98
37 changed files with 89 additions and 79 deletions

View File

@ -490,7 +490,7 @@ public:
isc_throw(BadValue, "invalid relay value " isc_throw(BadValue, "invalid relay value "
<< out_bindings[12]->getString()); << out_bindings[12]->getString());
} }
for (auto i = 0; i < relay_element->size(); ++i) { for (unsigned i = 0; i < relay_element->size(); ++i) {
auto relay_address_element = relay_element->get(i); auto relay_address_element = relay_element->get(i);
if (relay_address_element->getType() != Element::string) { if (relay_address_element->getType() != Element::string) {
isc_throw(BadValue, "relay address must be a string"); isc_throw(BadValue, "relay address must be a string");
@ -1414,7 +1414,7 @@ public:
isc_throw(BadValue, "invalid relay value " isc_throw(BadValue, "invalid relay value "
<< out_bindings[7]->getString()); << out_bindings[7]->getString());
} }
for (auto i = 0; i < relay_element->size(); ++i) { for (unsigned i = 0; i < relay_element->size(); ++i) {
auto relay_address_element = relay_element->get(i); auto relay_address_element = relay_element->get(i);
if (relay_address_element->getType() != Element::string) { if (relay_address_element->getType() != Element::string) {
isc_throw(BadValue, "relay address must be a string"); isc_throw(BadValue, "relay address must be a string");

View File

@ -503,7 +503,7 @@ public:
isc_throw(BadValue, "invalid relay value " isc_throw(BadValue, "invalid relay value "
<< out_bindings[8]->getString()); << out_bindings[8]->getString());
} }
for (auto i = 0; i < relay_element->size(); ++i) { for (unsigned i = 0; i < relay_element->size(); ++i) {
auto relay_address_element = relay_element->get(i); auto relay_address_element = relay_element->get(i);
if (relay_address_element->getType() != Element::string) { if (relay_address_element->getType() != Element::string) {
isc_throw(BadValue, "relay address must be a string"); isc_throw(BadValue, "relay address must be a string");
@ -1725,7 +1725,7 @@ public:
isc_throw(BadValue, "invalid relay value " isc_throw(BadValue, "invalid relay value "
<< out_bindings[8]->getString()); << out_bindings[8]->getString());
} }
for (auto i = 0; i < relay_element->size(); ++i) { for (unsigned i = 0; i < relay_element->size(); ++i) {
auto relay_address_element = relay_element->get(i); auto relay_address_element = relay_element->get(i);
if (relay_address_element->getType() != Element::string) { if (relay_address_element->getType() != Element::string) {
isc_throw(BadValue, "relay address must be a string"); isc_throw(BadValue, "relay address must be a string");

View File

@ -927,7 +927,7 @@ MySqlConfigBackendImpl::processOptionDefRow(MySqlBindingCollection::iterator fir
// This element must contain a list of integers specifying // This element must contain a list of integers specifying
// types of the record fields. // types of the record fields.
for (auto i = 0; i < record_types_element->size(); ++i) { for (unsigned i = 0; i < record_types_element->size(); ++i) {
auto type_element = record_types_element->get(i); auto type_element = record_types_element->get(i);
if (type_element->getType() != Element::integer) { if (type_element->getType() != Element::integer) {
isc_throw(BadValue, "record type values must be integers"); isc_throw(BadValue, "record type values must be integers");

View File

@ -904,7 +904,7 @@ PgSqlConfigBackendImpl::processOptionDefRow(PgSqlResultRowWorker& worker,
// This element must contain a list of integers specifying // This element must contain a list of integers specifying
// types of the record fields. // types of the record fields.
for (auto i = 0; i < record_types_element->size(); ++i) { for (unsigned i = 0; i < record_types_element->size(); ++i) {
auto type_element = record_types_element->get(i); auto type_element = record_types_element->get(i);
if (type_element->getType() != Element::integer) { if (type_element->getType() != Element::integer) {
isc_throw(BadValue, "record type values must be integers"); isc_throw(BadValue, "record type values must be integers");
@ -1127,7 +1127,7 @@ PgSqlConfigBackendImpl::setRelays(PgSqlResultRowWorker& worker, size_t col, Netw
isc_throw(BadValue, "invalid relay list: " << worker.getString(col)); isc_throw(BadValue, "invalid relay list: " << worker.getString(col));
} }
for (auto i = 0; i < relay_element->size(); ++i) { for (unsigned i = 0; i < relay_element->size(); ++i) {
auto relay_address_element = relay_element->get(i); auto relay_address_element = relay_element->get(i);
if (relay_address_element->getType() != Element::string) { if (relay_address_element->getType() != Element::string) {
isc_throw(BadValue, "elements of relay_addresses list must" isc_throw(BadValue, "elements of relay_addresses list must"

View File

@ -1446,7 +1446,7 @@ public:
/// rows to fetch. /// rows to fetch.
bool getNextRow(LeaseStatsRow& row) { bool getNextRow(LeaseStatsRow& row) {
// If we're past the end, punt. // If we're past the end, punt.
if (next_row_ >= result_set_->getRows()) { if (static_cast<int>(next_row_) >= result_set_->getRows()) {
return (false); return (false);
} }

View File

@ -76,7 +76,7 @@ IOAddress firstAddrInPrefix6(const IOAddress& prefix, uint8_t len) {
} }
// Clear out the remaining bits. // Clear out the remaining bits.
for (int i = len / 8; i < sizeof(packed); ++i) { for (unsigned i = len / 8; i < sizeof(packed); ++i) {
packed[i] = 0x0; packed[i] = 0x0;
} }
@ -156,7 +156,7 @@ IOAddress lastAddrInPrefix6(const IOAddress& prefix, uint8_t len) {
} }
// Finally set remaining bits to 1. // Finally set remaining bits to 1.
for (int i = len / 8; i < sizeof(packed); ++i) { for (unsigned i = len / 8; i < sizeof(packed); ++i) {
packed[i] = 0xff; packed[i] = 0xff;
} }

View File

@ -244,7 +244,7 @@ void
TestServerUnixSocket::generateCustomResponse(const uint64_t response_size) { TestServerUnixSocket::generateCustomResponse(const uint64_t response_size) {
std::ostringstream s; std::ostringstream s;
s << "{"; s << "{";
while (s.tellp() < response_size) { while (s.tellp() < static_cast<std::streampos>(response_size)) {
s << "\"param\": \"value\","; s << "\"param\": \"value\",";
} }
s << "}"; s << "}";

View File

@ -108,7 +108,7 @@ ClientClasses::fromElement(isc::data::ConstElementPtr cc_list) {
isc_throw(BadValue, "not a List element"); isc_throw(BadValue, "not a List element");
} }
for (auto i = 0; i < cc_list->size(); ++i) { for (unsigned i = 0; i < cc_list->size(); ++i) {
auto cclass = cc_list->get(i); auto cclass = cc_list->get(i);
if (cclass->getType() != Element::string) { if (cclass->getType() != Element::string) {
isc_throw(BadValue, "elements of list must be valid strings"); isc_throw(BadValue, "elements of list must be valid strings");

View File

@ -132,7 +132,7 @@ Iface::getPlainMac() const {
ostringstream tmp; ostringstream tmp;
tmp.fill('0'); tmp.fill('0');
tmp << hex; tmp << hex;
for (int i = 0; i < mac_len_; i++) { for (unsigned i = 0; i < mac_len_; i++) {
tmp.width(2); tmp.width(2);
tmp << static_cast<int>(mac_[i]); tmp << static_cast<int>(mac_[i]);
if (i < mac_len_-1) { if (i < mac_len_-1) {

View File

@ -52,7 +52,7 @@ OpaqueDataTuple::getText() const {
void void
OpaqueDataTuple::pack(isc::util::OutputBuffer& buf) const { OpaqueDataTuple::pack(isc::util::OutputBuffer& buf) const {
if ((1 << (getDataFieldSize() * 8)) <= getLength()) { if ((1U << (getDataFieldSize() * 8)) <= getLength()) {
isc_throw(OpaqueDataTupleError, "failed to create on-wire format of the" isc_throw(OpaqueDataTupleError, "failed to create on-wire format of the"
" opaque data field, because current data length " " opaque data field, because current data length "
<< getLength() << " exceeds the maximum size for the length" << getLength() << " exceeds the maximum size for the length"
@ -130,7 +130,7 @@ OpaqueDataTuple::unpack(OpaqueDataTuple::InputIterator begin, OpaqueDataTuple::I
// reminder of the buffer is long enough. // reminder of the buffer is long enough.
begin += getDataFieldSize(); begin += getDataFieldSize();
// Attempt to parse as a length-value pair. // Attempt to parse as a length-value pair.
if (std::distance(begin, end) < len) { if (static_cast<size_t>(std::distance(begin, end)) < len) {
if (Option::lenient_parsing_) { if (Option::lenient_parsing_) {
// Fallback to parsing the rest of the option as a single value. // Fallback to parsing the rest of the option as a single value.
len = std::distance(begin, end); len = std::distance(begin, end);

View File

@ -68,7 +68,7 @@ void Option6IA::unpack(OptionBufferConstIter begin,
OptionBufferConstIter end) { OptionBufferConstIter end) {
// IA_NA and IA_PD have 12 bytes content (iaid, t1, t2 fields) // IA_NA and IA_PD have 12 bytes content (iaid, t1, t2 fields)
// followed by 0 or more sub-options. // followed by 0 or more sub-options.
if (distance(begin, end) < OPTION6_IA_LEN) { if (static_cast<size_t>(distance(begin, end)) < OPTION6_IA_LEN) {
isc_throw(OutOfRange, "Option " << type_ << " truncated"); isc_throw(OutOfRange, "Option " << type_ << " truncated");
} }
iaid_ = readUint32(&(*begin), distance(begin, end)); iaid_ = readUint32(&(*begin), distance(begin, end));

View File

@ -70,7 +70,7 @@ void Option6IAAddr::pack(isc::util::OutputBuffer& buf, bool) const {
void Option6IAAddr::unpack(OptionBuffer::const_iterator begin, void Option6IAAddr::unpack(OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end) { OptionBuffer::const_iterator end) {
if ( distance(begin, end) < OPTION6_IAADDR_LEN) { if (static_cast<size_t>(distance(begin, end)) < OPTION6_IAADDR_LEN) {
isc_throw(OutOfRange, "Option " << type_ << " truncated"); isc_throw(OutOfRange, "Option " << type_ << " truncated");
} }

View File

@ -73,7 +73,7 @@ void Option6IAPrefix::pack(isc::util::OutputBuffer& buf, bool) const {
void Option6IAPrefix::unpack(OptionBuffer::const_iterator begin, void Option6IAPrefix::unpack(OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end) { OptionBuffer::const_iterator end) {
if ( distance(begin, end) < OPTION6_IAPREFIX_LEN) { if (static_cast<size_t>(distance(begin, end)) < OPTION6_IAPREFIX_LEN) {
isc_throw(OutOfRange, "Option " << type_ << " truncated"); isc_throw(OutOfRange, "Option " << type_ << " truncated");
} }

View File

@ -64,7 +64,7 @@ Option6StatusCode::pack(isc::util::OutputBuffer& buf, bool) const {
void void
Option6StatusCode::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) { Option6StatusCode::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
// Make sure that the option is not truncated. // Make sure that the option is not truncated.
if (std::distance(begin, end) < OPTION6_STATUS_CODE_MIN_LEN) { if (static_cast<size_t>(std::distance(begin, end)) < OPTION6_STATUS_CODE_MIN_LEN) {
isc_throw(OutOfRange, "Status Code option (" isc_throw(OutOfRange, "Status Code option ("
<< D6O_STATUS_CODE << ") truncated"); << D6O_STATUS_CODE << ") truncated");
} }
@ -174,7 +174,7 @@ Option4SlpServiceScope::pack(isc::util::OutputBuffer& buf, bool check) const {
void void
Option4SlpServiceScope::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) { Option4SlpServiceScope::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
// Make sure that the option is not truncated. // Make sure that the option is not truncated.
if (std::distance(begin, end) < OPTION4_SLP_SERVICE_SCOPEMIN_LEN) { if (static_cast<size_t>(std::distance(begin, end)) < OPTION4_SLP_SERVICE_SCOPEMIN_LEN) {
isc_throw(OutOfRange, "SLP Service Scope option (" isc_throw(OutOfRange, "SLP Service Scope option ("
<< DHO_SERVICE_SCOPE << ") truncated"); << DHO_SERVICE_SCOPE << ") truncated");
} }

View File

@ -152,7 +152,8 @@ OptionClasslessStaticRoute::parseWireData(OptionBufferConstIter begin, OptionBuf
++begin; ++begin;
// once we know haw many significant octets there are, check for truncated data again // once we know haw many significant octets there are, check for truncated data again
if (distance(begin, end) < (significant_octets + V4ADDRESS_LEN)) { if (static_cast<size_t>(distance(begin, end)) <
(significant_octets + V4ADDRESS_LEN)) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"DHCPv4 OptionClasslessStaticRoute " << type_ << " is truncated."); "DHCPv4 OptionClasslessStaticRoute " << type_ << " is truncated.");
} }

View File

@ -308,7 +308,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
// Our data field requires that there is a certain chunk of // Our data field requires that there is a certain chunk of
// data left in the buffer. If not, option is truncated. // data left in the buffer. If not, option is truncated.
if (std::distance(data, data_buf.end()) < data_size) { if (static_cast<size_t>(std::distance(data, data_buf.end())) < data_size) {
isc_throw(OutOfRange, "option buffer truncated"); isc_throw(OutOfRange, "option buffer truncated");
} }
@ -325,7 +325,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
size_t data_size = bufferLength(fields.back(), true, size_t data_size = bufferLength(fields.back(), true,
data, data_buf.end()); data, data_buf.end());
isc_throw_assert(data_size > 0); isc_throw_assert(data_size > 0);
if (std::distance(data, data_buf.end()) < data_size) { if (static_cast<size_t>(std::distance(data, data_buf.end())) < data_size) {
break; break;
} }
buffers.push_back(OptionBuffer(data, data + data_size)); buffers.push_back(OptionBuffer(data, data + data_size));
@ -350,7 +350,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
// Note that data_size returned by getDataTypeLen may be zero // Note that data_size returned by getDataTypeLen may be zero
// if variable length data is being held by the option but // if variable length data is being held by the option but
// this will not cause this check to throw exception. // this will not cause this check to throw exception.
if (std::distance(data, data_buf.end()) < data_size) { if (static_cast<size_t>(std::distance(data, data_buf.end())) < data_size) {
isc_throw(OutOfRange, "option buffer truncated"); isc_throw(OutOfRange, "option buffer truncated");
} }
// For an array of values we are taking different path because // For an array of values we are taking different path because
@ -369,7 +369,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
// data_size. Note that it is ok to truncate the data if and only // data_size. Note that it is ok to truncate the data if and only
// if the data buffer is long enough to keep at least one value. // if the data buffer is long enough to keep at least one value.
// This has been checked above already. // This has been checked above already.
if (std::distance(data, data_buf.end()) < data_size) { if (static_cast<size_t>(std::distance(data, data_buf.end())) < data_size) {
break; break;
} }
buffers.push_back(OptionBuffer(data, data + data_size)); buffers.push_back(OptionBuffer(data, data + data_size));
@ -380,7 +380,8 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
// getDataTypeLen returns zero for variable size data types // getDataTypeLen returns zero for variable size data types
// such as strings. Simply take whole buffer. // such as strings. Simply take whole buffer.
data_size = bufferLength(data_type, false, data, data_buf.end()); data_size = bufferLength(data_type, false, data, data_buf.end());
if ((data_size > 0) && (std::distance(data, data_buf.end()) >= data_size)) { if ((data_size > 0) &&
(static_cast<size_t>(std::distance(data, data_buf.end())) >= data_size)) {
buffers.push_back(OptionBuffer(data, data + data_size)); buffers.push_back(OptionBuffer(data, data + data_size));
data += data_size; data += data_size;
} else { } else {

View File

@ -772,7 +772,7 @@ OptionPtr
OptionDefinition::factoryIA6(uint16_t type, OptionDefinition::factoryIA6(uint16_t type,
OptionBufferConstIter begin, OptionBufferConstIter begin,
OptionBufferConstIter end) { OptionBufferConstIter end) {
if (std::distance(begin, end) < Option6IA::OPTION6_IA_LEN) { if (static_cast<size_t>(std::distance(begin, end)) < Option6IA::OPTION6_IA_LEN) {
isc_throw(isc::OutOfRange, "input option buffer has invalid size," isc_throw(isc::OutOfRange, "input option buffer has invalid size,"
<< " expected at least " << Option6IA::OPTION6_IA_LEN << " expected at least " << Option6IA::OPTION6_IA_LEN
<< " bytes"); << " bytes");
@ -785,7 +785,7 @@ OptionPtr
OptionDefinition::factoryIAAddr6(uint16_t type, OptionDefinition::factoryIAAddr6(uint16_t type,
OptionBufferConstIter begin, OptionBufferConstIter begin,
OptionBufferConstIter end) { OptionBufferConstIter end) {
if (std::distance(begin, end) < Option6IAAddr::OPTION6_IAADDR_LEN) { if (static_cast<size_t>(std::distance(begin, end)) < Option6IAAddr::OPTION6_IAADDR_LEN) {
isc_throw(isc::OutOfRange, isc_throw(isc::OutOfRange,
"input option buffer has invalid size, expected at least " "input option buffer has invalid size, expected at least "
<< Option6IAAddr::OPTION6_IAADDR_LEN << " bytes"); << Option6IAAddr::OPTION6_IAADDR_LEN << " bytes");
@ -799,7 +799,7 @@ OptionPtr
OptionDefinition::factoryIAPrefix6(uint16_t type, OptionDefinition::factoryIAPrefix6(uint16_t type,
OptionBufferConstIter begin, OptionBufferConstIter begin,
OptionBufferConstIter end) { OptionBufferConstIter end) {
if (std::distance(begin, end) < Option6IAPrefix::OPTION6_IAPREFIX_LEN) { if (static_cast<size_t>(std::distance(begin, end)) < Option6IAPrefix::OPTION6_IAPREFIX_LEN) {
isc_throw(isc::OutOfRange, isc_throw(isc::OutOfRange,
"input option buffer has invalid size, expected at least " "input option buffer has invalid size, expected at least "
<< Option6IAPrefix::OPTION6_IAPREFIX_LEN << " bytes"); << Option6IAPrefix::OPTION6_IAPREFIX_LEN << " bytes");

View File

@ -146,7 +146,7 @@ public:
/// equal to 1, 2 or 4 bytes. The data type is not checked in this function /// equal to 1, 2 or 4 bytes. The data type is not checked in this function
/// because it is checked in a constructor. /// because it is checked in a constructor.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end) { virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
if (distance(begin, end) < sizeof(T)) { if (static_cast<size_t>(distance(begin, end)) < sizeof(T)) {
isc_throw(OutOfRange, "OptionInt " << getType() << " truncated"); isc_throw(OutOfRange, "OptionInt " << getType() << " truncated");
} }
// @todo consider what to do if buffer is longer than data type. // @todo consider what to do if buffer is longer than data type.

View File

@ -60,7 +60,7 @@ OptionOpaqueDataTuples::unpack(OptionBufferConstIter begin,
// Start reading opaque data. // Start reading opaque data.
size_t offset = 0; size_t offset = 0;
while (offset < std::distance(begin, end)) { while (offset < static_cast<size_t>(std::distance(begin, end))) {
// Parse a tuple. // Parse a tuple.
OpaqueDataTuple tuple(length_field_type_, begin + offset, end); OpaqueDataTuple tuple(length_field_type_, begin + offset, end);
addTuple(tuple); addTuple(tuple);

View File

@ -71,7 +71,7 @@ OptionVendorClass::unpack(OptionBufferConstIter begin,
// Start reading opaque data. // Start reading opaque data.
size_t offset = 0; size_t offset = 0;
while (offset < std::distance(begin, end)) { while (offset < static_cast<size_t>(std::distance(begin, end))) {
// Parse a tuple. // Parse a tuple.
OpaqueDataTuple tuple(OptionDataTypeUtil::getTupleLenFieldType(getUniverse()), OpaqueDataTuple tuple(OptionDataTypeUtil::getTupleLenFieldType(getUniverse()),
begin + offset, end); begin + offset, end);

View File

@ -100,7 +100,7 @@ CfgExpiration::rangeCheck(const int64_t value, const uint64_t max_value,
isc_throw(OutOfRange, "value for configuration parameter '" isc_throw(OutOfRange, "value for configuration parameter '"
<< config_parameter_name << "' must not be negative"); << config_parameter_name << "' must not be negative");
} else if (value > max_value) { } else if (static_cast<uint64_t>(value) > max_value) {
isc_throw(OutOfRange, "out range value '" << value << "' for configuration" isc_throw(OutOfRange, "out range value '" << value << "' for configuration"
" parameter '" << config_parameter_name << "', expected maximum" " parameter '" << config_parameter_name << "', expected maximum"
" value of '" << max_value << "'"); " value of '" << max_value << "'");

View File

@ -47,7 +47,7 @@ FreeLeaseQueueAllocator::pickAddressInternal(const ClientClasses& client_classes
// Let's first iterate over the pools and identify the ones that // Let's first iterate over the pools and identify the ones that
// meet client class criteria and are not exhausted. // meet client class criteria and are not exhausted.
std::vector<uint64_t> available; std::vector<uint64_t> available;
for (auto i = 0; i < pools.size(); ++i) { for (unsigned i = 0; i < pools.size(); ++i) {
// Check if the pool is allowed for the client's classes. // Check if the pool is allowed for the client's classes.
if (pools[i]->clientSupported(client_classes)) { if (pools[i]->clientSupported(client_classes)) {
// Get or create the pool state. // Get or create the pool state.
@ -94,7 +94,7 @@ FreeLeaseQueueAllocator::pickPrefixInternal(const ClientClasses& client_classes,
// Let's first iterate over the pools and identify the ones that // Let's first iterate over the pools and identify the ones that
// meet client class criteria and are not exhausted. // meet client class criteria and are not exhausted.
std::vector<uint64_t> available; std::vector<uint64_t> available;
for (auto i = 0; i < pools.size(); ++i) { for (unsigned i = 0; i < pools.size(); ++i) {
// Check if the pool is allowed for the client's classes. // Check if the pool is allowed for the client's classes.
if (pools[i]->clientSupported(client_classes)) { if (pools[i]->clientSupported(client_classes)) {
if (!Allocator::isValidPrefixPool(prefix_length_match, pools[i], if (!Allocator::isValidPrefixPool(prefix_length_match, pools[i],

View File

@ -868,7 +868,7 @@ LeaseMgr::upgradeLease6ExtendedInfo(const Lease6Ptr& lease,
} }
verifying = "relay"; verifying = "relay";
for (i = 0; i < relay_info->size(); ++i) { for (i = 0; static_cast<size_t>(i) < relay_info->size(); ++i) {
ElementPtr relay = relay_info->getNonConst(i); ElementPtr relay = relay_info->getNonConst(i);
if (!relay) { if (!relay) {
mutable_isc->remove("relay-info"); mutable_isc->remove("relay-info");
@ -943,7 +943,7 @@ LeaseMgr::upgradeLease6ExtendedInfo(const Lease6Ptr& lease,
} }
verifying = "relay"; verifying = "relay";
for (i = 0; i < relay_info->size(); ++i) { for (i = 0; static_cast<size_t>(i) < relay_info->size(); ++i) {
ElementPtr relay = relay_info->getNonConst(i); ElementPtr relay = relay_info->getNonConst(i);
if (!upgraded && !relay) { if (!upgraded && !relay) {
mutable_isc->remove("relay-info"); mutable_isc->remove("relay-info");
@ -1235,7 +1235,7 @@ LeaseMgr::addExtendedInfo6(const Lease6Ptr& lease) {
return (added); return (added);
} }
for (int i = 0; i < relay_info->size(); ++i) { for (unsigned i = 0; i < relay_info->size(); ++i) {
ConstElementPtr relay = relay_info->get(i); ConstElementPtr relay = relay_info->get(i);
if (!relay || (relay->getType() != Element::map) || relay->empty()) { if (!relay || (relay->getType() != Element::map) || relay->empty()) {
continue; continue;

View File

@ -83,7 +83,7 @@ ClassLeaseCounter::adjustClassCounts(ConstElementPtr classes, int offset,
return; return;
} }
for (int i = 0; i < classes->size(); ++i) { for (unsigned i = 0; i < classes->size(); ++i) {
std::string class_name = classes->get(i)->stringValue(); std::string class_name = classes->get(i)->stringValue();
adjustClassCount(class_name, offset, ltype); adjustClassCount(class_name, offset, ltype);
} }

View File

@ -1411,7 +1411,8 @@ Memfile_LeaseMgr::getLeases4Internal(const asiolink::IOAddress& lower_bound_addr
// Return all other leases being within the page size. // Return all other leases being within the page size.
for (auto lease = lb; for (auto lease = lb;
(lease != idx.end()) && (std::distance(lb, lease) < page_size.page_size_); (lease != idx.end()) &&
(static_cast<size_t>(std::distance(lb, lease)) < page_size.page_size_);
++lease) { ++lease) {
collection.push_back(Lease4Ptr(new Lease4(**lease))); collection.push_back(Lease4Ptr(new Lease4(**lease)));
} }
@ -1686,7 +1687,8 @@ Memfile_LeaseMgr::getLeases6Internal(const asiolink::IOAddress& lower_bound_addr
// Return all other leases being within the page size. // Return all other leases being within the page size.
for (auto lease = lb; for (auto lease = lb;
(lease != idx.end()) && (std::distance(lb, lease) < page_size.page_size_); (lease != idx.end()) &&
(static_cast<size_t>(std::distance(lb, lease)) < page_size.page_size_);
++lease) { ++lease) {
collection.push_back(Lease6Ptr(new Lease6(**lease))); collection.push_back(Lease6Ptr(new Lease6(**lease)));
} }
@ -1789,8 +1791,9 @@ Memfile_LeaseMgr::getExpiredLeases4Internal(Lease4Collection& expired_leases,
// Copy only the number of leases indicated by the max_leases parameter. // Copy only the number of leases indicated by the max_leases parameter.
for (Lease4StorageExpirationIndex::const_iterator lease = index.begin(); for (Lease4StorageExpirationIndex::const_iterator lease = index.begin();
(lease != ub) && ((max_leases == 0) || (std::distance(index.begin(), lease) < (lease != ub) &&
max_leases)); ((max_leases == 0) ||
(static_cast<size_t>(std::distance(index.begin(), lease)) < max_leases));
++lease) { ++lease) {
expired_leases.push_back(Lease4Ptr(new Lease4(**lease))); expired_leases.push_back(Lease4Ptr(new Lease4(**lease)));
} }
@ -1825,8 +1828,9 @@ Memfile_LeaseMgr::getExpiredLeases6Internal(Lease6Collection& expired_leases,
// Copy only the number of leases indicated by the max_leases parameter. // Copy only the number of leases indicated by the max_leases parameter.
for (Lease6StorageExpirationIndex::const_iterator lease = index.begin(); for (Lease6StorageExpirationIndex::const_iterator lease = index.begin();
(lease != ub) && ((max_leases == 0) || (std::distance(index.begin(), lease) < (lease != ub) &&
max_leases)); ((max_leases == 0) ||
(static_cast<size_t>(std::distance(index.begin(), lease)) < max_leases));
++lease) { ++lease) {
expired_leases.push_back(Lease6Ptr(new Lease6(**lease))); expired_leases.push_back(Lease6Ptr(new Lease6(**lease)));
} }
@ -2718,7 +2722,7 @@ Memfile_LeaseMgr::checkLimits4(isc::data::ConstElementPtr const& user_context) c
// an "address-limit", check its value against the class's lease count. // an "address-limit", check its value against the class's lease count.
ConstElementPtr classes = limits->get("client-classes"); ConstElementPtr classes = limits->get("client-classes");
if (classes) { if (classes) {
for (int i = 0; i < classes->size(); ++i) { for (unsigned i = 0; i < classes->size(); ++i) {
ConstElementPtr class_elem = classes->get(i); ConstElementPtr class_elem = classes->get(i);
// Get class name. // Get class name.
ConstElementPtr name_elem = class_elem->get("name"); ConstElementPtr name_elem = class_elem->get("name");
@ -2776,7 +2780,7 @@ Memfile_LeaseMgr::checkLimits4(isc::data::ConstElementPtr const& user_context) c
} }
// If we're over the limit, return the error. // If we're over the limit, return the error.
if (lease_count >= limit) { if (static_cast<uint64_t>(lease_count) >= limit) {
std::ostringstream ss; std::ostringstream ss;
ss << "address limit " << limit << " for subnet ID " << subnet_id ss << "address limit " << limit << " for subnet ID " << subnet_id
<< ", current lease count " << lease_count; << ", current lease count " << lease_count;
@ -2805,7 +2809,7 @@ Memfile_LeaseMgr::checkLimits6(isc::data::ConstElementPtr const& user_context) c
// class lease count. // class lease count.
ConstElementPtr classes = limits->get("client-classes"); ConstElementPtr classes = limits->get("client-classes");
if (classes) { if (classes) {
for (int i = 0; i < classes->size(); ++i) { for (unsigned i = 0; i < classes->size(); ++i) {
ConstElementPtr class_elem = classes->get(i); ConstElementPtr class_elem = classes->get(i);
// Get class name. // Get class name.
ConstElementPtr name_elem = class_elem->get("name"); ConstElementPtr name_elem = class_elem->get("name");
@ -2877,7 +2881,7 @@ Memfile_LeaseMgr::checkLimits6(isc::data::ConstElementPtr const& user_context) c
} }
// If we're over the limit, return the error. // If we're over the limit, return the error.
if (lease_count >= limit) { if (static_cast<uint64_t>(lease_count) >= limit) {
std::ostringstream ss; std::ostringstream ss;
ss << (ltype == Lease::TYPE_NA ? "address" : "prefix") ss << (ltype == Lease::TYPE_NA ? "address" : "prefix")
<< " limit " << limit << " for subnet ID " << subnet_id << " limit " << limit << " for subnet ID " << subnet_id

View File

@ -180,7 +180,7 @@ PacketFuzzer::transfer(uint8_t const* data, size_t size) const {
// Now send the data to the UDP port on which Kea is listening. // Now send the data to the UDP port on which Kea is listening.
// Send the data to the main Kea thread. Limit the size of the // Send the data to the main Kea thread. Limit the size of the
// packets that can be sent. // packets that can be sent.
size_t send_len = (length < MAX_SEND_SIZE) ? length : MAX_SEND_SIZE; size_t send_len = (size < MAX_SEND_SIZE) ? size : MAX_SEND_SIZE;
ssize_t sent = sendto(sockfd_, buf, send_len, 0, sockaddr_ptr_, ssize_t sent = sendto(sockfd_, buf, send_len, 0, sockaddr_ptr_,
sockaddr_len_); sockaddr_len_);
if (sent < 0) { if (sent < 0) {

View File

@ -36,7 +36,7 @@ RandomAllocator::pickAddressInternal(const ClientClasses& client_classes,
// ones. // ones.
std::vector<uint64_t> available; std::vector<uint64_t> available;
std::vector<uint64_t> exhausted; std::vector<uint64_t> exhausted;
for (auto i = 0; i < pools.size(); ++i) { for (unsigned i = 0; i < pools.size(); ++i) {
// Check if the pool is allowed for the client's classes. // Check if the pool is allowed for the client's classes.
if (pools[i]->clientSupported(client_classes)) { if (pools[i]->clientSupported(client_classes)) {
// Get or create the pool state. // Get or create the pool state.
@ -99,7 +99,7 @@ RandomAllocator::pickPrefixInternal(const ClientClasses& client_classes,
// ones. // ones.
std::vector<uint64_t> available; std::vector<uint64_t> available;
std::vector<uint64_t> exhausted; std::vector<uint64_t> exhausted;
for (auto i = 0; i < pools.size(); ++i) { for (unsigned i = 0; i < pools.size(); ++i) {
// Check if the pool is allowed for the client's classes. // Check if the pool is allowed for the client's classes.
if (pools[i]->clientSupported(client_classes)) { if (pools[i]->clientSupported(client_classes)) {
if (!Allocator::isValidPrefixPool(prefix_length_match, pools[i], if (!Allocator::isValidPrefixPool(prefix_length_match, pools[i],

View File

@ -133,7 +133,8 @@ LabelSequence::serialize(void* buf, size_t buf_len) const {
std::memcpy(bp, &data_[offsets_[first_label_]], ndata_len); std::memcpy(bp, &data_[offsets_[first_label_]], ndata_len);
bp += ndata_len; bp += ndata_len;
isc_throw_assert(bp - reinterpret_cast<const uint8_t*>(buf) == expected_size); isc_throw_assert(bp - reinterpret_cast<const uint8_t*>(buf) ==
static_cast<const ssize_t>(expected_size));
} }
bool bool

View File

@ -154,7 +154,7 @@ MessageImpl::init() {
edns_ = EDNSPtr(); edns_ = EDNSPtr();
tsig_rr_ = ConstTSIGRecordPtr(); tsig_rr_ = ConstTSIGRecordPtr();
for (int i = 0; i < NUM_SECTIONS; ++i) { for (unsigned int i = 0; i < NUM_SECTIONS; ++i) {
counts_[i] = 0; counts_[i] = 0;
} }
@ -491,7 +491,7 @@ Message::getTSIGRecord() const {
unsigned int unsigned int
Message::getRRCount(const Section section) const { Message::getRRCount(const Section section) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
return (impl_->counts_[section]); return (impl_->counts_[section]);
@ -507,7 +507,7 @@ Message::addRRset(const Section section, RRsetPtr rrset) {
isc_throw(InvalidMessageOperation, isc_throw(InvalidMessageOperation,
"addRRset performed in non-render mode"); "addRRset performed in non-render mode");
} }
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
@ -519,7 +519,7 @@ Message::addRRset(const Section section, RRsetPtr rrset) {
bool bool
Message::hasRRset(const Section section, const Name& name, Message::hasRRset(const Section section, const Name& name,
const RRClass& rrclass, const RRType& rrtype) const { const RRClass& rrclass, const RRType& rrtype) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
@ -542,7 +542,7 @@ Message::hasRRset(const Section section, const RRsetPtr& rrset) const {
bool bool
Message::removeRRset(const Section section, RRsetIterator& iterator) { Message::removeRRset(const Section section, RRsetIterator& iterator) {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
@ -570,7 +570,7 @@ Message::clearSection(const Section section) {
isc_throw(InvalidMessageOperation, isc_throw(InvalidMessageOperation,
"clearSection performed in non-render mode"); "clearSection performed in non-render mode");
} }
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
if (section == Message::SECTION_QUESTION) { if (section == Message::SECTION_QUESTION) {
@ -658,7 +658,7 @@ MessageImpl::parseQuestion(InputBuffer& buffer) {
unsigned int added = 0; unsigned int added = 0;
for (unsigned int count = 0; for (unsigned int count = 0;
count < counts_[Message::SECTION_QUESTION]; static_cast<int>(count) < counts_[Message::SECTION_QUESTION];
++count) { ++count) {
const Name name(buffer); const Name name(buffer);
@ -732,13 +732,15 @@ struct MatchRR {
int int
MessageImpl::parseSection(const Message::Section section, MessageImpl::parseSection(const Message::Section section,
InputBuffer& buffer, Message::ParseOptions options) { InputBuffer& buffer, Message::ParseOptions options) {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
unsigned int added = 0; unsigned int added = 0;
for (unsigned int count = 0; count < counts_[section]; ++count) { for (unsigned int count = 0;
static_cast<int>(count) < counts_[section];
++count) {
// We need to remember the start position for TSIG processing // We need to remember the start position for TSIG processing
const size_t start_position = buffer.getPosition(); const size_t start_position = buffer.getPosition();
@ -847,7 +849,7 @@ MessageImpl::addTSIG(Message::Section section, unsigned int count,
isc_throw(DNSMessageFORMERR, isc_throw(DNSMessageFORMERR,
"TSIG RR found in an invalid section"); "TSIG RR found in an invalid section");
} }
if (count != counts_[section] - 1) { if (static_cast<int>(count) != counts_[section] - 1) {
isc_throw(DNSMessageFORMERR, "TSIG RR is not the last record"); isc_throw(DNSMessageFORMERR, "TSIG RR is not the last record");
} }
// This check will never fail as the multiple TSIG RR case is // This check will never fail as the multiple TSIG RR case is
@ -991,7 +993,7 @@ Message::clear(Mode mode) {
void void
Message::appendSection(const Section section, const Message& source) { Message::appendSection(const Section section, const Message& source) {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
@ -1135,7 +1137,7 @@ Message::endQuestion() const {
/// ///
const SectionIterator<RRsetPtr> const SectionIterator<RRsetPtr>
Message::beginSection(const Section section) const { Message::beginSection(const Section section) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
if (section == SECTION_QUESTION) { if (section == SECTION_QUESTION) {
@ -1148,7 +1150,7 @@ Message::beginSection(const Section section) const {
const SectionIterator<RRsetPtr> const SectionIterator<RRsetPtr>
Message::endSection(const Section section) const { Message::endSection(const Section section) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) { if (static_cast<unsigned int>(section) >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section)); isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
} }
if (section == SECTION_QUESTION) { if (section == SECTION_QUESTION) {

View File

@ -932,7 +932,7 @@ TokenSplit::evaluate(Pkt& pkt, ValueStack& values) {
boost::algorithm::token_compress_off); boost::algorithm::token_compress_off);
// Range check the field. // Range check the field.
if (field < 1 || field > fields.size()) { if (field < 1 || static_cast<size_t>(field) > fields.size()) {
// Push an empty string if field is out of range. // Push an empty string if field is out of range.
values.push(""); values.push("");
@ -1367,7 +1367,7 @@ TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) {
case DATA: case DATA:
{ {
size_t max = vendor->getTuplesNum(); size_t max = vendor->getTuplesNum();
if (index_ + 1 > max) { if (static_cast<size_t>(index_ + 1) > max) {
// The index specified is out of bounds, e.g. there are only // The index specified is out of bounds, e.g. there are only
// 2 tuples and index specified is 5. // 2 tuples and index specified is 5.
LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND) LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND)

View File

@ -95,7 +95,8 @@ CalloutManager::registerCallout(const std::string& name,
bool bool
CalloutManager::calloutsPresent(int hook_index) const { CalloutManager::calloutsPresent(int hook_index) const {
// Validate the hook index. // Validate the hook index.
if ((hook_index < 0) || (hook_index >= hook_vector_.size())) { if ((hook_index < 0) ||
(static_cast<size_t>(hook_index) >= hook_vector_.size())) {
isc_throw(NoSuchHook, "hook index " << hook_index << isc_throw(NoSuchHook, "hook index " << hook_index <<
" is not valid for the list of registered hooks"); " is not valid for the list of registered hooks");
} }
@ -242,7 +243,7 @@ CalloutManager::deregisterCallout(const std::string& name, CalloutPtr callout,
int hook_index = server_hooks_.getIndex(name); int hook_index = server_hooks_.getIndex(name);
// New hooks can have been registered since the manager was constructed. // New hooks can have been registered since the manager was constructed.
if (hook_index >= hook_vector_.size()) { if (static_cast<size_t>(hook_index) >= hook_vector_.size()) {
return (false); return (false);
} }
@ -340,7 +341,7 @@ CalloutManager::registerCommandHook(const std::string& command_name) {
void void
CalloutManager::ensureHookLibsVectorSize() { CalloutManager::ensureHookLibsVectorSize() {
ServerHooks& hooks = ServerHooks::getServerHooks(); ServerHooks& hooks = ServerHooks::getServerHooks();
if (hooks.getCount() > hook_vector_.size()) { if (static_cast<size_t>(hooks.getCount()) > hook_vector_.size()) {
// Uh oh, there are more hook points that our vector allows. // Uh oh, there are more hook points that our vector allows.
hook_vector_.resize(hooks.getCount()); hook_vector_.resize(hooks.getCount());
} }

View File

@ -83,7 +83,7 @@ LibraryHandle::getParameters() {
index = callout_manager_.getLibraryIndex(); index = callout_manager_.getLibraryIndex();
} }
if ((index > libinfo.size()) || (index <= 0)) { if ((index > static_cast<int>(libinfo.size())) || (index <= 0)) {
// Something is very wrong here. The library index is out of bounds. // Something is very wrong here. The library index is out of bounds.
// However, this is user facing interface, so we should not throw here. // However, this is user facing interface, so we should not throw here.
return (isc::data::ConstElementPtr()); return (isc::data::ConstElementPtr());

View File

@ -604,7 +604,7 @@ PgSqlConnection::executePreparedStatement(PgSqlTaggedStatement& statement,
const PsqlBindArray& in_bindings) { const PsqlBindArray& in_bindings) {
checkUnusable(); checkUnusable();
if (statement.nbparams != in_bindings.size()) { if (static_cast<size_t>(statement.nbparams) != in_bindings.size()) {
isc_throw (InvalidOperation, "executePreparedStatement:" isc_throw (InvalidOperation, "executePreparedStatement:"
<< " expected: " << statement.nbparams << " expected: " << statement.nbparams
<< " parameters, given: " << in_bindings.size() << " parameters, given: " << in_bindings.size()

View File

@ -295,7 +295,7 @@ PsqlBindArray::toText() const {
return ("bindarray is empty"); return ("bindarray is empty");
} }
for (int i = 0; i < values_.size(); ++i) { for (size_t i = 0; i < values_.size(); ++i) {
stream << i << " : "; stream << i << " : ";
if (lengths_[i] == 0) { if (lengths_[i] == 0) {

View File

@ -49,7 +49,7 @@ bool LogContentTest::checkFile() {
ifstream file(LOG_FILE); ifstream file(LOG_FILE);
EXPECT_TRUE(file.is_open()); EXPECT_TRUE(file.is_open());
string line, exp_line; string line, exp_line;
int i = 0; unsigned i = 0;
bool found = true; bool found = true;
using namespace std; using namespace std;

View File

@ -91,7 +91,7 @@ bool UnixControlClient::sendCommand(const std::string& command) {
} }
// Send command // Send command
int bytes_sent = send(socket_fd_, command.c_str(), command.length(), 0); int bytes_sent = send(socket_fd_, command.c_str(), command.length(), 0);
if (bytes_sent < command.length()) { if (bytes_sent < static_cast<int>(command.length())) {
const char* errmsg = strerror(errno); const char* errmsg = strerror(errno);
ADD_FAILURE() << "Failed to send " << command.length() ADD_FAILURE() << "Failed to send " << command.length()
<< " bytes, send() returned " << bytes_sent << " bytes, send() returned " << bytes_sent

View File

@ -153,7 +153,7 @@ void applyDelete(ConstElementPtr key, ElementPtr scope) {
return; return;
} else if (key->getType() == Element::integer) { } else if (key->getType() == Element::integer) {
int index = key->intValue(); int index = key->intValue();
if ((index >= 0) && (index < scope->size())) { if ((index >= 0) && (static_cast<size_t>(index) < scope->size())) {
scope->remove(index); scope->remove(index);
} }
} else if (key->getType() == Element::map) { } else if (key->getType() == Element::map) {
@ -166,7 +166,7 @@ void applyDelete(ConstElementPtr key, ElementPtr scope) {
if (name.empty()) { if (name.empty()) {
return; return;
} }
for (int i = 0; i < scope->size(); ++i) { for (unsigned i = 0; i < scope->size(); ++i) {
ElementPtr item = scope->getNonConst(i); ElementPtr item = scope->getNonConst(i);
if (!item || (item->getType() != Element::map)) { if (!item || (item->getType() != Element::map)) {
continue; continue;
@ -283,7 +283,7 @@ void applyDown(ConstElementPtr path, ConstElementPtr actions, ElementPtr scope,
for (ElementPtr& down : downs) { for (ElementPtr& down : downs) {
applyDown(path, actions, down, next); applyDown(path, actions, down, next);
} }
} else if ((index >= 0) && (index < scope->size())) { } else if ((index >= 0) && (static_cast<size_t>(index) < scope->size())) {
applyDown(path, actions, scope->getNonConst(index), next); applyDown(path, actions, scope->getNonConst(index), next);
} }
} }