Commit bf2e60ca authored by Stephen Morris's avatar Stephen Morris

[1470] Change some loop indexes to unsigned values

Some loops changed to use unsigned loop indexes to avoid warning
messages from some compilers.
parent 29003e06
......@@ -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();
}
}
......
......@@ -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);
......
......@@ -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]);
}
......
......@@ -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);
}
......
......@@ -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")
......
......@@ -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));
......
......@@ -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;
......
......@@ -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];
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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) {
......
......@@ -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";
......
......@@ -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]);
}
}
......
......@@ -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());
}
}
......@@ -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
......
......@@ -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.
......
......@@ -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);
}
}
......
......@@ -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]);
......
......@@ -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]);
......
......@@ -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);
......
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