summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorStephen Morris <stephen@isc.org>2011-12-12 18:09:00 +0100
committerStephen Morris <stephen@isc.org>2011-12-12 18:09:00 +0100
commitbf2e60ca2a5bd14d057c5ad292b752e980d9637b (patch)
tree74d604b1fcc6cadde5b1090341cb893073cd314e /src/lib
parent[1470] Qualify "error_code" (diff)
downloadkea-bf2e60ca2a5bd14d057c5ad292b752e980d9637b.tar.xz
kea-bf2e60ca2a5bd14d057c5ad292b752e980d9637b.zip
[1470] Change some loop indexes to unsigned values
Some loops changed to use unsigned loop indexes to avoid warning messages from some compilers.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/asiodns/tests/dns_server_unittest.cc2
-rw-r--r--src/lib/bench/benchmark.h2
-rw-r--r--src/lib/cache/resolver_cache.cc9
-rw-r--r--src/lib/cc/data.cc4
-rw-r--r--src/lib/cc/session.cc2
-rw-r--r--src/lib/cryptolink/tests/crypto_unittests.cc3
-rw-r--r--src/lib/dns/rdata/generic/dnskey_48.cc2
-rw-r--r--src/lib/dns/rdata/generic/nsec3_50.cc2
-rw-r--r--src/lib/dns/rdata/generic/nsec_47.cc2
-rw-r--r--src/lib/dns/rdatafields.cc4
-rw-r--r--src/lib/dns/tests/unittest_util.cc4
-rw-r--r--src/lib/log/compiler/message.cc2
-rw-r--r--src/lib/log/logger_manager.cc2
-rw-r--r--src/lib/log/tests/logger_manager_unittest.cc2
-rw-r--r--src/lib/nsas/hash_key.cc2
-rw-r--r--src/lib/resolve/response_classifier.cc9
-rw-r--r--src/lib/resolve/tests/recursive_query_unittest_2.cc2
-rw-r--r--src/lib/util/tests/base32hex_unittest.cc2
-rw-r--r--src/lib/util/tests/hex_unittest.cc2
-rw-r--r--src/lib/util/time_utilities.cc2
20 files changed, 33 insertions, 28 deletions
diff --git a/src/lib/asiodns/tests/dns_server_unittest.cc b/src/lib/asiodns/tests/dns_server_unittest.cc
index 1ef3192f35..c79ee7f472 100644
--- a/src/lib/asiodns/tests/dns_server_unittest.cc
+++ b/src/lib/asiodns/tests/dns_server_unittest.cc
@@ -430,7 +430,7 @@ TEST_F(DNSServerTest, stopUDPServerDuringPrepareAnswer) {
}
static void stopServerManyTimes(DNSServer *server, unsigned int times) {
- for (int i = 0; i < times; ++i) {
+ for (unsigned int i = 0; i < times; ++i) {
server->stop();
}
}
diff --git a/src/lib/bench/benchmark.h b/src/lib/bench/benchmark.h
index 5eab1b74e5..7f77aa19ec 100644
--- a/src/lib/bench/benchmark.h
+++ b/src/lib/bench/benchmark.h
@@ -261,7 +261,7 @@ public:
struct timeval beg, end;
gettimeofday(&beg, NULL);
- for (int i = 0; i < iterations_; ++i) {
+ for (unsigned int i = 0; i < iterations_; ++i) {
sub_iterations_ += target_.run();
}
gettimeofday(&end, NULL);
diff --git a/src/lib/cache/resolver_cache.cc b/src/lib/cache/resolver_cache.cc
index 57935c06ea..20f470effb 100644
--- a/src/lib/cache/resolver_cache.cc
+++ b/src/lib/cache/resolver_cache.cc
@@ -164,14 +164,16 @@ ResolverCache::ResolverCache()
ResolverCache::ResolverCache(std::vector<CacheSizeInfo> caches_info)
{
- for (int i = 0; i < caches_info.size(); ++i) {
+ for (std::vector<CacheSizeInfo>::size_type i = 0;
+ i < caches_info.size(); ++i) {
class_caches_.push_back(new ResolverClassCache(caches_info[i]));
}
}
ResolverCache::~ResolverCache()
{
- for (int i = 0; i < class_caches_.size(); ++i) {
+ for (std::vector<ResolverClassCache*>::size_type i = 0;
+ i < class_caches_.size(); ++i) {
delete class_caches_[i];
}
}
@@ -261,7 +263,8 @@ ResolverCache::update(const isc::dns::ConstRRsetPtr& rrset_ptr) {
ResolverClassCache*
ResolverCache::getClassCache(const isc::dns::RRClass& cache_class) const {
- for (int i = 0; i < class_caches_.size(); ++i) {
+ for (std::vector<ResolverClassCache*>::size_type i = 0;
+ i < class_caches_.size(); ++i) {
if (class_caches_[i]->getClass() == cache_class) {
return (class_caches_[i]);
}
diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc
index ffa5346a84..3ebc4f80cc 100644
--- a/src/lib/cc/data.cc
+++ b/src/lib/cc/data.cc
@@ -780,11 +780,11 @@ StringElement::equals(const Element& other) const {
bool
ListElement::equals(const Element& other) const {
if (other.getType() == Element::list) {
- const int s = size();
+ const size_t s = size();
if (s != other.size()) {
return (false);
}
- for (int i = 0; i < s; ++i) {
+ for (size_t i = 0; i < s; ++i) {
if (!get(i)->equals(*other.get(i))) {
return (false);
}
diff --git a/src/lib/cc/session.cc b/src/lib/cc/session.cc
index 0052aca884..1b21d213d2 100644
--- a/src/lib/cc/session.cc
+++ b/src/lib/cc/session.cc
@@ -367,7 +367,7 @@ Session::recvmsg(ConstElementPtr& env, ConstElementPtr& msg,
size_t length = impl_->readDataLength();
if (hasQueuedMsgs()) {
ConstElementPtr q_el;
- for (int i = 0; i < impl_->queue_->size(); i++) {
+ for (size_t i = 0; i < impl_->queue_->size(); i++) {
q_el = impl_->queue_->get(i);
if (( seq == -1 &&
!q_el->get(0)->contains("reply")
diff --git a/src/lib/cryptolink/tests/crypto_unittests.cc b/src/lib/cryptolink/tests/crypto_unittests.cc
index 4abeb87a68..df94c1283b 100644
--- a/src/lib/cryptolink/tests/crypto_unittests.cc
+++ b/src/lib/cryptolink/tests/crypto_unittests.cc
@@ -392,7 +392,8 @@ doRFC4231Tests(HashAlgorithm hash_algorithm,
ASSERT_EQ(secret_list.size(), data_list.size());
ASSERT_EQ(secret_list.size(), hmac_list.size());
- for (int i = 0; i < data_list.size(); ++i) {
+ for (std::vector<std::string>::size_type i = 0;
+ i < data_list.size(); ++i) {
SCOPED_TRACE("RFC4231 HMAC test for algorithm ID: " +
lexical_cast<std::string>(hash_algorithm) +
", data ID: " + lexical_cast<std::string>(i));
diff --git a/src/lib/dns/rdata/generic/dnskey_48.cc b/src/lib/dns/rdata/generic/dnskey_48.cc
index e0f5461b01..7bdbd0514d 100644
--- a/src/lib/dns/rdata/generic/dnskey_48.cc
+++ b/src/lib/dns/rdata/generic/dnskey_48.cc
@@ -181,7 +181,7 @@ DNSKEY::getTag() const {
ac += impl_->algorithm_;
size_t size = impl_->keydata_.size();
- for (int i = 0; i < size; i ++) {
+ for (size_t i = 0; i < size; i ++) {
ac += (i & 1) ? impl_->keydata_[i] : (impl_->keydata_[i] << 8);
}
ac += (ac >> 16) & 0xffff;
diff --git a/src/lib/dns/rdata/generic/nsec3_50.cc b/src/lib/dns/rdata/generic/nsec3_50.cc
index 3bd0bb2d50..092695c082 100644
--- a/src/lib/dns/rdata/generic/nsec3_50.cc
+++ b/src/lib/dns/rdata/generic/nsec3_50.cc
@@ -221,7 +221,7 @@ string
NSEC3::toText() const {
ostringstream s;
int len = 0;
- for (int i = 0; i < impl_->typebits_.size(); i += len) {
+ for (size_t i = 0; i < impl_->typebits_.size(); i += len) {
assert(i + 2 <= impl_->typebits_.size());
int window = impl_->typebits_[i];
len = impl_->typebits_[i + 1];
diff --git a/src/lib/dns/rdata/generic/nsec_47.cc b/src/lib/dns/rdata/generic/nsec_47.cc
index 4723c236da..a9a9f7517f 100644
--- a/src/lib/dns/rdata/generic/nsec_47.cc
+++ b/src/lib/dns/rdata/generic/nsec_47.cc
@@ -143,7 +143,7 @@ NSEC::toText() const {
// and easier to find a bug (if any). Note that this conversion method
// is generally not expected to be very efficient, so the slight overhead
// of at() should be acceptable.
- for (int i = 0; i < impl_->typebits_.size(); i += len) {
+ for (size_t i = 0; i < impl_->typebits_.size(); i += len) {
assert(i + 2 <= impl_->typebits_.size());
const int block = impl_->typebits_.at(i);
len = impl_->typebits_.at(i + 1);
diff --git a/src/lib/dns/rdatafields.cc b/src/lib/dns/rdatafields.cc
index d3f282be13..af9ba2e886 100644
--- a/src/lib/dns/rdatafields.cc
+++ b/src/lib/dns/rdatafields.cc
@@ -171,7 +171,7 @@ RdataFields::RdataFields(const void* fields, const unsigned int fields_length,
}
size_t total_length = 0;
- for (int i = 0; i < nfields_; ++i) {
+ for (unsigned int i = 0; i < nfields_; ++i) {
total_length += fields_[i].len;
}
if (total_length != data_length_) {
@@ -198,7 +198,7 @@ void
RdataFields::toWire(AbstractMessageRenderer& renderer) const {
size_t offset = 0;
- for (int i = 0; i < nfields_; ++i) {
+ for (unsigned int i = 0; i < nfields_; ++i) {
if (fields_[i].type == DATA) {
renderer.writeData(data_ + offset, fields_[i].len);
} else {
diff --git a/src/lib/dns/tests/unittest_util.cc b/src/lib/dns/tests/unittest_util.cc
index c9c09826ad..ca9d34719f 100644
--- a/src/lib/dns/tests/unittest_util.cc
+++ b/src/lib/dns/tests/unittest_util.cc
@@ -116,7 +116,7 @@ UnitTestUtil::readWireData(const string& datastr,
throw runtime_error(err_oss.str());
}
- for (int pos = 0; pos < bytes.size(); pos += 2) {
+ for (string::size_type pos = 0; pos < bytes.size(); pos += 2) {
istringstream iss_byte(bytes.substr(pos, 2));
unsigned int ch;
@@ -139,7 +139,7 @@ UnitTestUtil::matchWireData(const char*, const char*, const char*, const char*,
::testing::Message msg;
size_t cmplen = min(len1, len2);
- for (int i = 0; i < cmplen; i++) {
+ for (size_t i = 0; i < cmplen; i++) {
int ch1 = static_cast<const uint8_t*>(data1)[i];
int ch2 = static_cast<const uint8_t*>(data2)[i];
if (ch1 != ch2) {
diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc
index f74020a762..3c8a3f2fec 100644
--- a/src/lib/log/compiler/message.cc
+++ b/src/lib/log/compiler/message.cc
@@ -224,7 +224,7 @@ writeOpeningNamespace(ostream& output, const vector<string>& ns) {
if (!ns.empty()) {
// Output namespaces in correct order
- for (int i = 0; i < ns.size(); ++i) {
+ for (vector<string>::size_type i = 0; i < ns.size(); ++i) {
output << "namespace " << ns[i] << " {\n";
}
output << "\n";
diff --git a/src/lib/log/logger_manager.cc b/src/lib/log/logger_manager.cc
index 70e0d6f32f..a04fffb07b 100644
--- a/src/lib/log/logger_manager.cc
+++ b/src/lib/log/logger_manager.cc
@@ -167,7 +167,7 @@ LoggerManager::readLocalMessageFile(const char* file) {
// Log the variable number of arguments. The actual message will be
// logged when the error_message variable is destroyed.
Formatter<isc::log::Logger> error_message = logger.error(ident);
- for (int i = 0; i < args.size(); ++i) {
+ for (vector<string>::size_type i = 0; i < args.size(); ++i) {
error_message = error_message.arg(args[i]);
}
}
diff --git a/src/lib/log/tests/logger_manager_unittest.cc b/src/lib/log/tests/logger_manager_unittest.cc
index 0bdfc74822..9eb85ad48f 100644
--- a/src/lib/log/tests/logger_manager_unittest.cc
+++ b/src/lib/log/tests/logger_manager_unittest.cc
@@ -315,7 +315,7 @@ TEST_F(LoggerManagerTest, FileSizeRollover) {
EXPECT_FALSE(file3.good());
// Tidy up
- for (int i = 0; i < prev_name.size(); ++i) {
+ for (vector<string>::size_type i = 0; i < prev_name.size(); ++i) {
(void) unlink(prev_name[i].c_str());
}
}
diff --git a/src/lib/nsas/hash_key.cc b/src/lib/nsas/hash_key.cc
index bf4676b7cc..782e3d8583 100644
--- a/src/lib/nsas/hash_key.cc
+++ b/src/lib/nsas/hash_key.cc
@@ -35,7 +35,7 @@ bool HashKey::operator==(const isc::nsas::HashKey& other) {
// variation (stops on the first null byte).
//
// TODO: Use a lookup table to map upper to lower case (for speed)
- for (int i = 0; i < other.keylen; ++i) {
+ for (uint32_t i = 0; i < other.keylen; ++i) {
if (tolower(static_cast<unsigned char>(other.key[i])) !=
tolower(static_cast<unsigned char>(key[i]))) {
return false; // Mismatch
diff --git a/src/lib/resolve/response_classifier.cc b/src/lib/resolve/response_classifier.cc
index 02808e42c8..27c5cfcb1c 100644
--- a/src/lib/resolve/response_classifier.cc
+++ b/src/lib/resolve/response_classifier.cc
@@ -119,7 +119,7 @@ ResponseClassifier::Category ResponseClassifier::classify(
if (authority.empty()) {
return (EMPTY);
}
- for (int i = 0; i < authority.size(); ++i) {
+ for (vector<RRsetPtr>::size_type i = 0; i < authority.size(); ++i) {
if (authority[i]->getType() == RRType::NS()) {
return (REFERRAL);
}
@@ -161,7 +161,7 @@ ResponseClassifier::Category ResponseClassifier::classify(
// There are multiple RRsets in the answer. They should all have the same
// QCLASS, else there is some error in the response.
- for (int i = 1; i < answer.size(); ++i) {
+ for (vector<RRsetPtr>::size_type i = 1; i < answer.size(); ++i) {
if (answer[0]->getClass() != answer[i]->getClass()) {
return (MULTICLASS);
}
@@ -173,7 +173,8 @@ ResponseClassifier::Category ResponseClassifier::classify(
// CNAME - in which case there should no other record types at that QNAME.
if (question.getType() == RRType::ANY()) {
bool all_same = true;
- for (int i = 1; (i < answer.size()) && all_same; ++i) {
+ for (vector<RRsetPtr>::size_type i = 1; (i < answer.size()) && all_same;
+ ++i) {
all_same = (answer[0]->getName() == answer[i]->getName());
}
if (all_same) {
@@ -211,7 +212,7 @@ ResponseClassifier::Category ResponseClassifier::cnameChase(
{
// Search through the vector of RRset pointers until we find one with the
// right QNAME.
- for (int i = 0; i < ansrrset.size(); ++i) {
+ for (vector<RRsetPtr>::size_type i = 0; i < ansrrset.size(); ++i) {
if (present[i]) {
// This entry has not been logically removed, so look at it.
diff --git a/src/lib/resolve/tests/recursive_query_unittest_2.cc b/src/lib/resolve/tests/recursive_query_unittest_2.cc
index ba93bd845b..a222240969 100644
--- a/src/lib/resolve/tests/recursive_query_unittest_2.cc
+++ b/src/lib/resolve/tests/recursive_query_unittest_2.cc
@@ -698,7 +698,7 @@ TEST_F(RecursiveQueryTest2, Resolve) {
// weren't, we would expect some absurdly high answers.
vector<uint32_t> rtt = recorder->getRtt();
EXPECT_GT(rtt.size(), 0);
- for (int i = 0; i < rtt.size(); ++i) {
+ for (vector<uint32_t>::size_type i = 0; i < rtt.size(); ++i) {
EXPECT_LT(rtt[i], 2000);
}
}
diff --git a/src/lib/util/tests/base32hex_unittest.cc b/src/lib/util/tests/base32hex_unittest.cc
index fa4a29065c..89d441e620 100644
--- a/src/lib/util/tests/base32hex_unittest.cc
+++ b/src/lib/util/tests/base32hex_unittest.cc
@@ -154,7 +154,7 @@ TEST_F(Base32HexTest, decodeMap) {
}
TEST_F(Base32HexTest, encodeMap) {
- for (int i = 0; i < 32; ++i) {
+ for (uint8_t i = 0; i < 32; ++i) {
decoded_data.assign(4, 0);
decoded_data.push_back(i);
EXPECT_EQ(encoding_chars[i], encodeBase32Hex(decoded_data)[7]);
diff --git a/src/lib/util/tests/hex_unittest.cc b/src/lib/util/tests/hex_unittest.cc
index 52bcceabf9..efb842f0ac 100644
--- a/src/lib/util/tests/hex_unittest.cc
+++ b/src/lib/util/tests/hex_unittest.cc
@@ -110,7 +110,7 @@ TEST_F(HexTest, decodeMap) {
}
TEST_F(HexTest, encodeMap) {
- for (int i = 0; i < 16; ++i) {
+ for (uint8_t i = 0; i < 16; ++i) {
decoded_data.clear();
decoded_data.push_back(i);
EXPECT_EQ(encoding_chars[i], encodeHex(decoded_data)[1]);
diff --git a/src/lib/util/time_utilities.cc b/src/lib/util/time_utilities.cc
index 9303ab5f06..c756382273 100644
--- a/src/lib/util/time_utilities.cc
+++ b/src/lib/util/time_utilities.cc
@@ -158,7 +158,7 @@ uint64_t
timeFromText64(const string& time_txt) {
// Confirm the source only consists digits. sscanf() allows some
// minor exceptions.
- for (int i = 0; i < time_txt.length(); ++i) {
+ for (string::size_type i = 0; i < time_txt.length(); ++i) {
if (!isdigit(time_txt.at(i))) {
isc_throw(InvalidTime, "Couldn't convert non-numeric time value: "
<< time_txt);