Browse Source

[master] Finished merge of trac3833 (unsigned for indexes)

Francis Dupont 10 years ago
parent
commit
3db9f1d78f
48 changed files with 183 additions and 168 deletions
  1. 6 0
      ChangeLog
  2. 2 2
      src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
  3. 5 5
      src/bin/dhcp4/tests/dhcp4_test_utils.cc
  4. 2 2
      src/bin/dhcp6/tests/dhcp6_client.cc
  5. 1 1
      src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
  6. 1 1
      src/bin/dhcp6/tests/dhcp6_test_utils.h
  7. 10 10
      src/bin/perfdhcp/command_options.cc
  8. 1 1
      src/bin/perfdhcp/pkt_transform.cc
  9. 3 3
      src/bin/perfdhcp/test_control.cc
  10. 2 2
      src/bin/perfdhcp/tests/command_options_helper.h
  11. 2 2
      src/bin/perfdhcp/tests/command_options_unittest.cc
  12. 4 4
      src/bin/perfdhcp/tests/perf_pkt4_unittest.cc
  13. 2 2
      src/bin/perfdhcp/tests/perf_pkt6_unittest.cc
  14. 9 7
      src/bin/perfdhcp/tests/test_control_unittest.cc
  15. 1 1
      src/lib/dhcp/classify.cc
  16. 2 2
      src/lib/dhcp/libdhcp++.cc
  17. 3 3
      src/lib/dhcp/option.cc
  18. 2 2
      src/lib/dhcp/option_custom.cc
  19. 2 2
      src/lib/dhcp/option_int_array.h
  20. 2 2
      src/lib/dhcp/option_vendor_class.cc
  21. 1 1
      src/lib/dhcp/pkt6.cc
  22. 8 5
      src/lib/dhcp/tests/iface_mgr_unittest.cc
  23. 2 2
      src/lib/dhcp/tests/libdhcp++_unittest.cc
  24. 5 5
      src/lib/dhcp/tests/opaque_data_tuple_unittest.cc
  25. 1 1
      src/lib/dhcp/tests/option6_addrlst_unittest.cc
  26. 1 1
      src/lib/dhcp/tests/option6_ia_unittest.cc
  27. 1 1
      src/lib/dhcp/tests/option6_iaaddr_unittest.cc
  28. 1 1
      src/lib/dhcp/tests/option6_iaprefix_unittest.cc
  29. 10 10
      src/lib/dhcp/tests/option_custom_unittest.cc
  30. 12 10
      src/lib/dhcp/tests/option_definition_unittest.cc
  31. 2 2
      src/lib/dhcp/tests/option_int_array_unittest.cc
  32. 2 2
      src/lib/dhcp/tests/option_int_unittest.cc
  33. 5 5
      src/lib/dhcp/tests/option_unittest.cc
  34. 15 15
      src/lib/dhcp/tests/pkt4_unittest.cc
  35. 1 1
      src/lib/dhcp/tests/pkt6_unittest.cc
  36. 3 3
      src/lib/dhcp/tests/protocol_util_unittest.cc
  37. 1 1
      src/lib/dhcpsrv/parsers/dhcp_parsers.cc
  38. 11 11
      src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
  39. 3 3
      src/lib/dhcpsrv/tests/d2_udp_unittest.cc
  40. 12 12
      src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
  41. 3 3
      src/lib/dhcpsrv/tests/host_mgr_unittest.cc
  42. 2 2
      src/lib/dns/master_loader.cc
  43. 2 2
      src/lib/dns/tests/rdata_sshfp_unittest.cc
  44. 5 3
      src/lib/dns/tests/zone_checker_unittest.cc
  45. 3 3
      src/lib/hooks/library_manager.cc
  46. 2 2
      src/lib/hooks/library_manager_collection.cc
  47. 2 2
      src/lib/hooks/tests/server_hooks_unittest.cc
  48. 5 5
      src/lib/util/csv_file.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+952.	[bug]		fdupont
+	Made some loop indexes an unsigned type to avoid compiler warnings
+	where the termination condition is comparison with an unsigned
+	value.
+	(Trac #3833, git xxx)
+
 951.	[build]		fdupont
 	Removed BUNDY configuration backend.
 	(Trac #3732, git 96364cbbb15318c8f55d5b287cda0990d3eaae32)

+ 2 - 2
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc

@@ -3325,7 +3325,7 @@ TEST_F(Dhcpv4SrvTest, acceptMessageType) {
     };
     size_t allowed_size = sizeof(allowed) / sizeof(allowed[0]);
     // Check that the server actually accepts these message types.
-    for (int i = 0; i < allowed_size; ++i) {
+    for (size_t i = 0; i < allowed_size; ++i) {
         EXPECT_TRUE(srv.acceptMessageType(Pkt4Ptr(new Pkt4(allowed[i], 1234))))
             << "Test failed for message type " << i;
     }
@@ -3343,7 +3343,7 @@ TEST_F(Dhcpv4SrvTest, acceptMessageType) {
     };
     size_t not_allowed_size = sizeof(not_allowed) / sizeof(not_allowed[0]);
     // Actually check that the server will drop these messages.
-    for (int i = 0; i < not_allowed_size; ++i) {
+    for (size_t i = 0; i < not_allowed_size; ++i) {
         EXPECT_FALSE(srv.acceptMessageType(Pkt4Ptr(new Pkt4(not_allowed[i],
                                                             1234))))
             << "Test failed for message type " << i;

+ 5 - 5
src/bin/dhcp4/tests/dhcp4_test_utils.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -228,7 +228,7 @@ Dhcpv4SrvTest::noRequestedOptions(const Pkt4Ptr& pkt) {
 OptionPtr Dhcpv4SrvTest::generateClientId(size_t size /*= 4*/) {
 
     OptionBuffer clnt_id(size);
-    for (int i = 0; i < size; i++) {
+    for (size_t i = 0; i < size; i++) {
         clnt_id[i] = 100 + i;
     }
 
@@ -242,7 +242,7 @@ OptionPtr Dhcpv4SrvTest::generateClientId(size_t size /*= 4*/) {
 HWAddrPtr Dhcpv4SrvTest::generateHWAddr(size_t size /*= 6*/) {
     const uint8_t hw_type = 123; // Just a fake number (typically 6=HTYPE_ETHER, see dhcp4.h)
     OptionBuffer mac(size);
-    for (int i = 0; i < size; ++i) {
+    for (size_t i = 0; i < size; ++i) {
         mac[i] = 50 + i;
     }
     return (HWAddrPtr(new HWAddr(mac, hw_type)));
@@ -435,12 +435,12 @@ Dhcpv4SrvTest::testDiscoverRequest(const uint8_t msg_type) {
 
     // Initialize the source HW address.
     vector<uint8_t> mac(6);
-    for (int i = 0; i < 6; ++i) {
+    for (uint8_t i = 0; i < 6; ++i) {
         mac[i] = i * 10;
     }
     // Initialized the destination HW address.
     vector<uint8_t> dst_mac(6);
-    for (int i = 0; i < 6; ++i) {
+    for (uint8_t i = 0; i < 6; ++i) {
         dst_mac[i] = i * 20;
     }
     // Create a DHCP message. It will be used to simulate the

+ 2 - 2
src/bin/dhcp6/tests/dhcp6_client.cc

@@ -179,7 +179,7 @@ Dhcp6Client::applyRcvdConfiguration(const Pkt6Ptr& reply) {
 void
 Dhcp6Client::applyLease(const LeaseInfo& lease_info) {
     // Go over existing leases and try to match the one that we have.
-    for (int i = 0; i < config_.leases_.size(); ++i) {
+    for (size_t i = 0; i < config_.leases_.size(); ++i) {
         Lease6 existing_lease = config_.leases_[i].lease_;
         // If IAID is matching and there is an actual address assigned
         // replace the current lease. The default address is :: if the
@@ -422,7 +422,7 @@ Dhcp6Client::doConfirm() {
 void
 Dhcp6Client::fastFwdTime(const uint32_t secs) {
     // Iterate over all leases and move their cltt backwards.
-    for (int i = 0; i < config_.leases_.size(); ++i) {
+    for (size_t i = 0; i < config_.leases_.size(); ++i) {
         config_.leases_[i].lease_.cltt_ -= secs;
     }
 }

+ 1 - 1
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc

@@ -2090,7 +2090,7 @@ OptionPtr createRSOO(const std::vector<uint16_t> codes, uint8_t payload = 0) {
     }
     OptionPtr rsoo_container(new OptionCustom(*def, Option::V6));
 
-    for (int i = 0; i < codes.size(); ++i) {
+    for (size_t i = 0; i < codes.size(); ++i) {
         OptionBuffer buf(10, payload ? payload : codes[i]); // let's make the option 10 bytes long
         rsoo_container->addOption(OptionPtr(new Option(Option::V6, codes[i], buf)));
     }

+ 1 - 1
src/bin/dhcp6/tests/dhcp6_test_utils.h

@@ -170,7 +170,7 @@ public:
     isc::dhcp::OptionPtr generateClientId(size_t duid_size = 32) {
 
         isc::dhcp::OptionBuffer clnt_duid(duid_size);
-        for (int i = 0; i < duid_size; i++) {
+        for (size_t i = 0; i < duid_size; i++) {
             clnt_duid[i] = 100 + i;
         }
 

+ 10 - 10
src/bin/perfdhcp/command_options.cc

@@ -617,7 +617,7 @@ CommandOptions::decodeDuid(const std::string& base) {
     check(b.length() == 0, "no duid specified");
 
     // Turn pairs of hexadecimal digits into vector of octets
-    for (int i = 0; i < b.length(); i += 2) {
+    for (size_t i = 0; i < b.length(); i += 2) {
         unsigned int ui = 0;
         try {
             // Do actual conversion
@@ -671,7 +671,7 @@ uint8_t
 CommandOptions::convertHexString(const std::string& text) const {
     unsigned int ui = 0;
     // First, check if we are dealing with hexadecimal digits only
-    for (int i = 0; i < text.length(); ++i) {
+    for (size_t i = 0; i < text.length(); ++i) {
         if (!std::isxdigit(text[i])) {
             isc_throw(isc::InvalidParameter,
                       "The following digit: " << text[i] << " in "
@@ -840,22 +840,22 @@ CommandOptions::printCommandLine() const {
     if (clients_num_ != 0) {
         std::cout << "clients=" << clients_num_ << std::endl;
     }
-    for (int i = 0; i < base_.size(); ++i) {
+    for (size_t i = 0; i < base_.size(); ++i) {
         std::cout << "base[" << i << "]=" << base_[i] <<  std::endl;
     }
-    for (int i = 0; i < num_request_.size(); ++i) {
+    for (size_t i = 0; i < num_request_.size(); ++i) {
         std::cout << "num-request[" << i << "]=" << num_request_[i] << std::endl;
     }
     if (period_ != 0) {
         std::cout << "test-period=" << period_ << std::endl;
     }
-    for (int i = 0; i < drop_time_.size(); ++i) {
+    for (size_t i = 0; i < drop_time_.size(); ++i) {
         std::cout << "drop-time[" << i << "]=" << drop_time_[i] << std::endl;
     }
-    for (int i = 0; i < max_drop_.size(); ++i) {
+    for (size_t i = 0; i < max_drop_.size(); ++i) {
         std::cout << "max-drop{" << i << "]=" << max_drop_[i] << std::endl;
     }
-    for (int i = 0; i < max_pdrop_.size(); ++i) {
+    for (size_t i = 0; i < max_pdrop_.size(); ++i) {
         std::cout << "max-pdrop{" << i << "]=" << max_pdrop_[i] << std::endl;
     }
     if (preload_ != 0) {
@@ -877,16 +877,16 @@ CommandOptions::printCommandLine() const {
     if (use_first_) {
         std::cout << "use-first" << std::endl;
     }
-    for (int i = 0; i < template_file_.size(); ++i) {
+    for (size_t i = 0; i < template_file_.size(); ++i) {
         std::cout << "template-file[" << i << "]=" << template_file_[i] << std::endl;
     }
-    for (int i = 0; i < xid_offset_.size(); ++i) {
+    for (size_t i = 0; i < xid_offset_.size(); ++i) {
         std::cout << "xid-offset[" << i << "]=" << xid_offset_[i] << std::endl;
     }
     if (elp_offset_ != 0) {
         std::cout << "elp-offset=" << elp_offset_ << std::endl;
     }
-    for (int i = 0; i < rnd_offset_.size(); ++i) {
+    for (size_t i = 0; i < rnd_offset_.size(); ++i) {
         std::cout << "rnd-offset[" << i << "]=" << rnd_offset_[i] << std::endl;
     }
     if (sid_offset_ != 0) {

+ 1 - 1
src/bin/perfdhcp/pkt_transform.cc

@@ -147,7 +147,7 @@ PktTransform::packOptions(const OptionBuffer& in_buffer,
             // inject contents of temporary buffer to output buffer.
             const uint8_t *buf_data =
                 static_cast<const uint8_t*>(buf.getData());
-            for (int i = 0; i < buf.getLength(); ++i) {
+            for (size_t i = 0; i < buf.getLength(); ++i) {
                 out_buffer.writeUint8At(buf_data[i], offset + i);
             }
         }

+ 3 - 3
src/bin/perfdhcp/test_control.cc

@@ -393,7 +393,7 @@ TestControl::factoryIana6(Option::Universe, uint16_t,
         0, 0, 5400 >> 8, 5400 & 0xff,   // T2 = 5400
     };
     OptionBuffer buf_ia_na(buf_array, buf_array + sizeof(buf_array));
-    for (int i = 0;  i < buf.size(); ++i) {
+    for (size_t i = 0;  i < buf.size(); ++i) {
         buf_ia_na.push_back(buf[i]);
     }
     return (OptionPtr(new Option(Option::V6, D6O_IA_NA, buf_ia_na)));
@@ -1036,7 +1036,7 @@ TestControl::readPacketTemplate(const std::string& file_name) {
     // apart from spaces the file contains hexadecimal digits
     // only.
     std::vector<char> hex_digits;
-    for (int i = 0; i < file_contents.size(); ++i) {
+    for (size_t i = 0; i < file_contents.size(); ++i) {
         if (isxdigit(file_contents[i])) {
             hex_digits.push_back(file_contents[i]);
         } else if (!isxdigit(file_contents[i]) &&
@@ -1052,7 +1052,7 @@ TestControl::readPacketTemplate(const std::string& file_name) {
         isc_throw(OutOfRange, "template file " << file_name << " is empty");
     }
     std::vector<uint8_t> binary_stream;
-    for (int i = 0; i < hex_digits.size(); i += 2) {
+    for (size_t i = 0; i < hex_digits.size(); i += 2) {
         stringstream s;
         s << "0x" << hex_digits[i] << hex_digits[i+1];
         int b;

+ 2 - 2
src/bin/perfdhcp/tests/command_options_helper.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -123,7 +123,7 @@ private:
             // Allocate array of C-strings where we will store tokens
             results = new char*[tokens.size()];
             // Store tokens in C-strings array
-            for (int i = 0; i < tokens.size(); ++i) {
+            for (size_t i = 0; i < tokens.size(); ++i) {
                 size_t cs_size = tokens[i].length() + 1;
                 char* cs = new char[cs_size];
                 strncpy(cs, tokens[i].c_str(), cs_size);

+ 2 - 2
src/bin/perfdhcp/tests/command_options_unittest.cc

@@ -218,11 +218,11 @@ protected:
         EXPECT_EQ(0, opt.getBase().size());
         EXPECT_EQ(0, opt.getNumRequests().size());
         EXPECT_EQ(0, opt.getPeriod());
-        for (int i = 0; i < opt.getDropTime().size(); ++i) {
+        for (size_t i = 0; i < opt.getDropTime().size(); ++i) {
             EXPECT_DOUBLE_EQ(1, opt.getDropTime()[i]);
         }
         ASSERT_EQ(opt.getMaxDrop().size(), opt.getMaxDropPercentage().size());
-        for (int i = 0; i < opt.getMaxDrop().size(); ++i) {
+        for (size_t i = 0; i < opt.getMaxDrop().size(); ++i) {
             EXPECT_EQ(0, opt.getMaxDrop()[i]);
             EXPECT_EQ(0, opt.getMaxDropPercentage()[i]);
         }

+ 4 - 4
src/bin/perfdhcp/tests/perf_pkt4_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -114,7 +114,7 @@ public:
 TEST_F(PerfPkt4Test, Constructor) {
     // Initialize some dummy payload.
     uint8_t data[250];
-    for (int i = 0; i < 250; ++i) {
+    for (uint8_t i = 0; i < 250; ++i) {
         data[i] = i;
     }
 
@@ -354,7 +354,7 @@ TEST_F(PerfPkt4Test, UnpackTransactionId) {
 
     // Assume that transaction id is at offset 100.
     // Fill 4 bytes at offset 100 with dummy transaction id.
-    for (int i = 100; i < 104; ++i) {
+    for (uint8_t i = 100; i < 104; ++i) {
         in_data[i] = i - 99;
     }
 
@@ -386,7 +386,7 @@ TEST_F(PerfPkt4Test, Writes) {
     dhcp::OptionBuffer in_data(260, 1);
     // Initialize buffer to be used for write: 1,2,3,4,...,9
     dhcp::OptionBuffer write_buf(10);
-    for (int i = 0; i < write_buf.size(); ++i) {
+    for (size_t i = 0; i < write_buf.size(); ++i) {
         write_buf[i] = i;
     }
     // Create packet from the input buffer.

+ 2 - 2
src/bin/perfdhcp/tests/perf_pkt6_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -300,7 +300,7 @@ TEST_F(PerfPkt6Test, UnpackTransactionId) {
     uint8_t data[100] = { 0 };
 
     // Generate transaction id = 0x010203 and inject at offset = 50.
-    for (int i = 50; i <  53; ++i) {
+    for (uint8_t i = 50; i <  53; ++i) {
         data[i] = i - 49;
     }
     // Create packet and point out that transaction id is at offset 50.

+ 9 - 7
src/bin/perfdhcp/tests/test_control_unittest.cc

@@ -183,7 +183,7 @@ public:
         if (!temp_file.is_open()) {
             return (false);
         }
-        for (int i = 0; i < buf.size(); ++i) {
+        for (size_t i = 0; i < buf.size(); ++i) {
             int first_digit = buf[i] / 16;
             int second_digit = buf[i] % 16;
             // Insert two spaces between two hexadecimal digits.
@@ -254,7 +254,7 @@ public:
                               const dhcp::OptionBuffer& buf) const {
         size_t matched_num = 0;
         for (size_t i = 0; i < buf.size(); ++i) {
-            for (int j = 0; j < requested_options.size(); ++j) {
+            for (size_t j = 0; j < requested_options.size(); ++j) {
                 if (requested_options[j] == buf[i]) {
                     // Requested option has been found.
                     ++matched_num;
@@ -283,7 +283,7 @@ public:
         }
         size_t matched_num = 0;
         for (size_t i = 0; i < buf.size(); i += 2) {
-            for (int j = 0; j < requested_options.size(); j += 2) {
+            for (size_t j = 0; j < requested_options.size(); j += 2) {
                 uint16_t opt_i = (buf[i + 1] << 8) + (buf[i] & 0xFF);
                 uint16_t opt_j = (requested_options[j + 1] << 8)
                     + (requested_options[j] & 0xFF);
@@ -770,7 +770,8 @@ public:
         // Simulate Advertise responses from the server. Each advertise is
         // assigned a transaction id from the range of 1 to 10, so as they
         // match the transaction ids from the Solicit messages.
-        for (int i = generator->getNext() - 10; i < generator->getNext(); ++i) {
+        for (unsigned i = generator->getNext() - 10;
+             i < generator->getNext(); ++i) {
             Pkt6Ptr advertise(createAdvertisePkt6(i));
             // If Advertise is matched with the Solicit the call below will
             // trigger a corresponding Request. They will be assigned
@@ -782,7 +783,8 @@ public:
         // Requests have been sent, so now let's simulate responses from the
         // server. Generate corresponding Reply messages with the transaction
         // ids from the range from 11 to 20.
-        for (int i = generator->getNext() - 10; i < generator->getNext(); ++i) {
+        for (unsigned i = generator->getNext() - 10;
+             i < generator->getNext(); ++i) {
             Pkt6Ptr reply(createReplyPkt6(i));
             // Each Reply packet corresponds to the new lease acquired. Since
             // -f<renew-rate> option has been specified, received Reply
@@ -1385,10 +1387,10 @@ TEST_F(TestControlTest, PacketTemplates) {
     std::string file1("test1.hex");
     std::vector<uint8_t> template2(233);
     std::string file2("test2.hex");
-    for (int i = 0; i < template1.size(); ++i) {
+    for (size_t i = 0; i < template1.size(); ++i) {
         template1[i] = static_cast<uint8_t>(random() % 256);
     }
-    for (int i = 0; i < template2.size(); ++i) {
+    for (size_t i = 0; i < template2.size(); ++i) {
         template2[i] = static_cast<uint8_t>(random() % 256);
     }
     // Size of the file is 2 times larger than binary data size.

+ 1 - 1
src/lib/dhcp/classify.cc

@@ -28,7 +28,7 @@ ClientClasses::ClientClasses(const std::string& class_names)
     std::vector<std::string> split_text;
     boost::split(split_text, class_names, boost::is_any_of(","),
                  boost::algorithm::token_compress_off);
-    for (int i = 0; i < split_text.size(); ++i) {
+    for (size_t i = 0; i < split_text.size(); ++i) {
         std::string trimmed = util::str::trim(split_text[i]);
         // Ignore empty class names.
         if (!trimmed.empty()) {

+ 2 - 2
src/lib/dhcp/libdhcp++.cc

@@ -710,7 +710,7 @@ void initOptionSpace(OptionDefContainer& defs,
                      size_t params_size) {
     defs.clear();
 
-    for (int i = 0; i < params_size; ++i) {
+    for (size_t i = 0; i < params_size; ++i) {
         std::string encapsulates(params[i].encapsulates);
         if (!encapsulates.empty() && params[i].array) {
             isc_throw(isc::BadValue, "invalid standard option definition: "
@@ -740,7 +740,7 @@ void initOptionSpace(OptionDefContainer& defs,
 
         }
 
-        for (int rec = 0; rec < params[i].records_size; ++rec) {
+        for (size_t rec = 0; rec < params[i].records_size; ++rec) {
             definition->addRecordField(params[i].records[rec]);
         }
 

+ 3 - 3
src/lib/dhcp/option.cc

@@ -151,7 +151,7 @@ uint16_t Option::len() {
     // option header)
 
     // length of the whole option is header and data stored in this option...
-    int length = getHeaderLen() + data_.size();
+    size_t length = getHeaderLen() + data_.size();
 
     // ... and sum of lengths of all suboptions
     for (OptionCollection::iterator it = options_.begin();
@@ -160,10 +160,10 @@ uint16_t Option::len() {
         length += (*it).second->len();
     }
 
-    // note that this is not equal to lenght field. This value denotes
+    // note that this is not equal to length field. This value denotes
     // number of bytes required to store this option. length option should
     // contain (len()-getHeaderLen()) value.
-    return (length);
+    return (static_cast<uint16_t>(length));
 }
 
 bool

+ 2 - 2
src/lib/dhcp/option_custom.cc

@@ -504,7 +504,7 @@ OptionCustom::unpack(OptionBufferConstIter begin,
 uint16_t
 OptionCustom::len() {
     // The length of the option is a sum of option header ...
-    int length = getHeaderLen();
+    size_t length = getHeaderLen();
 
     // ... lengths of all buffers that hold option data ...
     for (std::vector<OptionBuffer>::const_iterator buf = buffers_.begin();
@@ -519,7 +519,7 @@ OptionCustom::len() {
         length += (*it).second->len();
     }
 
-    return (length);
+    return (static_cast<uint16_t>(length));
 }
 
 void OptionCustom::initialize(const OptionBufferConstIter first,

+ 2 - 2
src/lib/dhcp/option_int_array.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2013,2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -143,7 +143,7 @@ public:
         // Pack option header.
         packHeader(buf);
         // Pack option data.
-        for (int i = 0; i < values_.size(); ++i) {
+        for (size_t i = 0; i < values_.size(); ++i) {
             // Depending on the data type length we use different utility functions
             // writeUint16 or writeUint32 which write the data in the network byte
             // order to the provided buffer. The same functions can be safely used

+ 2 - 2
src/lib/dhcp/option_vendor_class.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -174,7 +174,7 @@ OptionVendorClass::toText(int indent) {
     s << "type=" << getType() << ", len=" << len() - getHeaderLen() << ", "
         " enterprise id=0x" << std::hex << getVendorId() << std::dec;
     // Iterate over all tuples and print their size and contents.
-    for (int i = 0; i < getTuplesNum(); ++i) {
+    for (unsigned i = 0; i < getTuplesNum(); ++i) {
         // The DHCPv4 V-I Vendor Class has enterprise id before every tuple.
         if ((getUniverse() == V4) && (i > 0)) {
             s << ", enterprise id=0x" << std::hex << getVendorId() << std::dec;

+ 1 - 1
src/lib/dhcp/pkt6.cc

@@ -639,7 +639,7 @@ void Pkt6::copyRelayInfo(const Pkt6Ptr& question) {
 
     // We use index rather than iterator, because we need that as a parameter
     // passed to getRelayOption()
-    for (int i = 0; i < question->relay_info_.size(); ++i) {
+    for (size_t i = 0; i < question->relay_info_.size(); ++i) {
         RelayInfo info;
         info.msg_type_ = DHCPV6_RELAY_REPL;
         info.hop_count_ = question->relay_info_[i].hop_count_;

+ 8 - 5
src/lib/dhcp/tests/iface_mgr_unittest.cc

@@ -77,14 +77,14 @@ TEST(IfaceTest, readBuffer) {
     ASSERT_FALSE(buf_ptr == NULL);
 
     // Use the pointer to set some data.
-    for (int i = 0; i < iface.getReadBufferSize(); ++i) {
+    for (size_t i = 0; i < iface.getReadBufferSize(); ++i) {
         buf_ptr[i] = i;
     }
 
     // Get the pointer again and validate the data.
     buf_ptr = iface.getReadBuffer();
     ASSERT_EQ(256, iface.getReadBufferSize());
-    for (int i = 0; i < iface.getReadBufferSize(); ++i) {
+    for (size_t i = 0; i < iface.getReadBufferSize(); ++i) {
         // Use assert so as it fails on the first failure, no need
         // to continue further checks.
         ASSERT_EQ(i, buf_ptr[i]);
@@ -552,7 +552,7 @@ TEST_F(IfaceMgrTest, closeSockets) {
 
     // Create set of V4 and V6 sockets on the loopback interface.
     // They must differ by a port they are bound to.
-    for (int i = 0; i < 6; ++i) {
+    for (unsigned i = 0; i < 6; ++i) {
         // Every other socket will be IPv4.
         if (i % 2) {
             ASSERT_NO_THROW(
@@ -1099,7 +1099,7 @@ TEST_F(IfaceMgrTest, sendReceive6) {
 
     // prepare dummy payload
     uint8_t data[128];
-    for (int i = 0; i < 128; i++) {
+    for (uint8_t i = 0; i < 128; i++) {
         data[i] = i;
     }
     Pkt6Ptr sendPkt = Pkt6Ptr(new Pkt6(data, 128));
@@ -2114,9 +2114,12 @@ TEST_F(IfaceMgrTest, iface_methods) {
     iface.setHWType(42);
     EXPECT_EQ(42, iface.getHWType());
 
+    ASSERT_LT(Iface::MAX_MAC_LEN + 10, 255);
+
     uint8_t mac[Iface::MAX_MAC_LEN+10];
-    for (int i = 0; i < Iface::MAX_MAC_LEN + 10; i++)
+    for (uint8_t i = 0; i < Iface::MAX_MAC_LEN + 10; i++) {
         mac[i] = 255 - i;
+    }
 
     EXPECT_EQ("foo", iface.getName());
     EXPECT_EQ(1234, iface.getIndex());

+ 2 - 2
src/lib/dhcp/tests/libdhcp++_unittest.cc

@@ -310,7 +310,7 @@ TEST_F(LibDhcpTest, packOptions6) {
     isc::dhcp::OptionCollection opts; // list of options
 
     // generate content for options
-    for (int i = 0; i < 64; i++) {
+    for (unsigned i = 0; i < 64; i++) {
         buf[i]=i+100;
     }
 
@@ -477,7 +477,7 @@ static uint8_t v4_opts[] = {
 TEST_F(LibDhcpTest, packOptions4) {
 
     vector<uint8_t> payload[5];
-    for (int i = 0; i < 5; i++) {
+    for (unsigned i = 0; i < 5; i++) {
         payload[i].resize(3);
         payload[i][0] = i*10;
         payload[i][1] = i*10+1;

+ 5 - 5
src/lib/dhcp/tests/opaque_data_tuple_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -267,7 +267,7 @@ TEST(OpaqueDataTuple, pack1Byte) {
     EXPECT_THROW(tuple.pack(out_buf), OpaqueDataTupleError);
     // Set the data for tuple.
     std::vector<uint8_t> data;
-    for (int i = 0; i < 100; ++i) {
+    for (uint8_t i = 0; i < 100; ++i) {
         data.push_back(i);
     }
     tuple.assign(data.begin(), data.size());
@@ -289,7 +289,7 @@ TEST(OpaqueDataTuple, pack1Byte) {
     out_buf.clear();
     // Fill in the tuple buffer so as it reaches maximum allowed length. The
     // maximum length is 255 when the size of the length field is one byte.
-    for (int i = 100; i < 255; ++i) {
+    for (uint8_t i = 100; i < 255; ++i) {
         data.push_back(i);
     }
     ASSERT_EQ(255, data.size());
@@ -326,8 +326,8 @@ TEST(OpaqueDataTuple, pack2Bytes) {
     EXPECT_THROW(tuple.pack(out_buf), OpaqueDataTupleError);
     // Set the data for tuple.
     std::vector<uint8_t> data;
-    for (int i = 0; i < 512; ++i) {
-        data.push_back(i);
+    for (unsigned i = 0; i < 512; ++i) {
+        data.push_back(i & 0xff);
     }
     tuple.assign(data.begin(), data.size());
     // The pack should now succeed.

+ 1 - 1
src/lib/dhcp/tests/option6_addrlst_unittest.cc

@@ -39,7 +39,7 @@ namespace {
 class Option6AddrLstTest : public ::testing::Test {
 public:
     Option6AddrLstTest(): buf_(255), outBuf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }

+ 1 - 1
src/lib/dhcp/tests/option6_ia_unittest.cc

@@ -40,7 +40,7 @@ namespace {
 class Option6IATest : public ::testing::Test {
 public:
     Option6IATest(): buf_(255), outBuf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }

+ 1 - 1
src/lib/dhcp/tests/option6_iaaddr_unittest.cc

@@ -38,7 +38,7 @@ namespace {
 class Option6IAAddrTest : public ::testing::Test {
 public:
     Option6IAAddrTest() : buf_(255), outBuf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }

+ 1 - 1
src/lib/dhcp/tests/option6_iaprefix_unittest.cc

@@ -38,7 +38,7 @@ namespace {
 class Option6IAPrefixTest : public ::testing::Test {
 public:
     Option6IAPrefixTest() : buf_(255), out_buf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }

+ 10 - 10
src/lib/dhcp/tests/option_custom_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2013,2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -196,7 +196,7 @@ TEST_F(OptionCustomTest, binaryData) {
     // used as reference when we read back the data from a created
     // option.
     OptionBuffer buf_in(14);
-    for (int i = 0; i < 14; ++i) {
+    for (unsigned i = 0; i < 14; ++i) {
         buf_in[i] = i;
     }
 
@@ -603,7 +603,7 @@ TEST_F(OptionCustomTest, uint32DataArray) {
 
     // Store these values in a buffer.
     OptionBuffer buf;
-    for (int i = 0; i < values.size(); ++i) {
+    for (size_t i = 0; i < values.size(); ++i) {
         writeInt<uint32_t>(values[i], buf);
     }
     // Create custom option using the input buffer.
@@ -649,7 +649,7 @@ TEST_F(OptionCustomTest, ipv4AddressDataArray) {
 
     // Store the collection of IPv4 addresses into the buffer.
     OptionBuffer buf;
-    for (int i = 0; i < addresses.size(); ++i) {
+    for (size_t i = 0; i < addresses.size(); ++i) {
         writeAddress(addresses[i], buf);
     }
 
@@ -699,7 +699,7 @@ TEST_F(OptionCustomTest, ipv6AddressDataArray) {
 
     // Store the collection of IPv6 addresses into the buffer.
     OptionBuffer buf;
-    for (int i = 0; i < addresses.size(); ++i) {
+    for (size_t i = 0; i < addresses.size(); ++i) {
         writeAddress(addresses[i], buf);
     }
 
@@ -968,7 +968,7 @@ TEST_F(OptionCustomTest, setBinaryData) {
     EXPECT_TRUE(buf.empty());
     // Prepare input buffer with some dummy data.
     OptionBuffer buf_in(10);
-    for (int i = 0; i < buf_in.size(); ++i) {
+    for (size_t i = 0; i < buf_in.size(); ++i) {
         buf_in[i] = i;
     }
     // Try to override the default binary buffer.
@@ -1433,7 +1433,7 @@ TEST_F(OptionCustomTest, unpack) {
 
     // Store the collection of IPv4 addresses into the buffer.
     OptionBuffer buf;
-    for (int i = 0; i < addresses.size(); ++i) {
+    for (size_t i = 0; i < addresses.size(); ++i) {
         writeAddress(addresses[i], buf);
     }
 
@@ -1464,7 +1464,7 @@ TEST_F(OptionCustomTest, unpack) {
 
     // Clear the buffer as we need to store new addresses in it.
     buf.clear();
-    for (int i = 0; i < addresses.size(); ++i) {
+    for (size_t i = 0; i < addresses.size(); ++i) {
         writeAddress(addresses[i], buf);
     }
 
@@ -1495,7 +1495,7 @@ TEST_F(OptionCustomTest, initialize) {
 
     // Store the collection of IPv6 addresses into the buffer.
     OptionBuffer buf;
-    for (int i = 0; i < addresses.size(); ++i) {
+    for (size_t i = 0; i < addresses.size(); ++i) {
         writeAddress(addresses[i], buf);
     }
 
@@ -1525,7 +1525,7 @@ TEST_F(OptionCustomTest, initialize) {
 
     // Clear the buffer as we need to store new addresses in it.
     buf.clear();
-    for (int i = 0; i < addresses.size(); ++i) {
+    for (size_t i = 0; i < addresses.size(); ++i) {
         writeAddress(addresses[i], buf);
     }
 

+ 12 - 10
src/lib/dhcp/tests/option_definition_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -356,7 +356,7 @@ TEST_F(OptionDefinitionTest, ipv6AddressArray) {
 
     // Write addresses to the buffer.
     OptionBuffer buf(addrs.size() * asiolink::V6ADDRESS_LEN);
-    for (int i = 0; i < addrs.size(); ++i) {
+    for (size_t i = 0; i < addrs.size(); ++i) {
         const std::vector<uint8_t>& vec = addrs[i].toBytes();
         ASSERT_EQ(asiolink::V6ADDRESS_LEN, vec.size());
         std::copy(vec.begin(), vec.end(),
@@ -454,7 +454,7 @@ TEST_F(OptionDefinitionTest, ipv4AddressArray) {
 
     // Write addresses to the buffer.
     OptionBuffer buf(addrs.size() * asiolink::V4ADDRESS_LEN);
-    for (int i = 0; i < addrs.size(); ++i) {
+    for (size_t i = 0; i < addrs.size(); ++i) {
         const std::vector<uint8_t> vec = addrs[i].toBytes();
         ASSERT_EQ(asiolink::V4ADDRESS_LEN, vec.size());
         std::copy(vec.begin(), vec.end(),
@@ -613,7 +613,7 @@ TEST_F(OptionDefinitionTest, binary) {
 
     // Prepare some dummy data (serverid): 0, 1, 2 etc.
     OptionBuffer buf(14);
-    for (int i = 0; i < 14; ++i) {
+    for (unsigned i = 0; i < 14; ++i) {
         buf[i] = i;
     }
     // Create option instance with the factory function.
@@ -666,7 +666,7 @@ TEST_F(OptionDefinitionTest, recordIA6) {
 
     // Check the positive scenario.
     OptionBuffer buf(12);
-    for (int i = 0; i < buf.size(); ++i) {
+    for (size_t i = 0; i < buf.size(); ++i) {
         buf[i] = i;
     }
     OptionPtr option_v6;
@@ -708,7 +708,9 @@ TEST_F(OptionDefinitionTest, recordIAAddr6) {
     ASSERT_EQ(asiolink::V6ADDRESS_LEN, vec.size());
     std::copy(vec.begin(), vec.end(), buf.begin());
 
-    for (int i = 0; i < option6_iaaddr_len - asiolink::V6ADDRESS_LEN; ++i) {
+    for (unsigned i = 0;
+         i < option6_iaaddr_len - asiolink::V6ADDRESS_LEN;
+         ++i) {
         buf.push_back(i);
     }
     ASSERT_NO_THROW(option_v6 = opt_def.optionFactory(Option::V6, D6O_IAADDR, buf));
@@ -1030,7 +1032,7 @@ TEST_F(OptionDefinitionTest, uint16Array) {
     // multiple of uint16_t size.
     // buffer elements will be: 0x112233.
     OptionBuffer buf(6);
-    for (int i = 0; i < 6; ++i) {
+    for (unsigned i = 0; i < 6; ++i) {
         buf[i] = i / 2;
     }
     // Constructor should succeed because buffer has correct size.
@@ -1042,7 +1044,7 @@ TEST_F(OptionDefinitionTest, uint16Array) {
         boost::static_pointer_cast<OptionIntArray<uint16_t> >(option_v6);
     // Get the values from the initiated options and validate.
     std::vector<uint16_t> values = option_cast_v6->getValues();
-    for (int i = 0; i < values.size(); ++i) {
+    for (size_t i = 0; i < values.size(); ++i) {
         // Expected value is calculated using on the same pattern
         // as the one we used to initiate buffer:
         // for i=0, expected = 0x00, for i = 1, expected == 0x11 etc.
@@ -1103,7 +1105,7 @@ TEST_F(OptionDefinitionTest, uint32Array) {
     // multiple of uint16_t size.
     // buffer elements will be: 0x111122223333.
     OptionBuffer buf(12);
-    for (int i = 0; i < buf.size(); ++i) {
+    for (size_t i = 0; i < buf.size(); ++i) {
         buf[i] = i / 4;
     }
     // Constructor should succeed because buffer has correct size.
@@ -1115,7 +1117,7 @@ TEST_F(OptionDefinitionTest, uint32Array) {
         boost::static_pointer_cast<OptionIntArray<uint32_t> >(option_v6);
     // Get the values from the initiated options and validate.
     std::vector<uint32_t> values = option_cast_v6->getValues();
-    for (int i = 0; i < values.size(); ++i) {
+    for (size_t i = 0; i < values.size(); ++i) {
         // Expected value is calculated using on the same pattern
         // as the one we used to initiate buffer:
         // for i=0, expected = 0x0000, for i = 1, expected == 0x1111 etc.

+ 2 - 2
src/lib/dhcp/tests/option_int_array_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012,2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -38,7 +38,7 @@ public:
     ///
     /// Initializes the option buffer with some data.
     OptionIntArrayTest(): buf_(255), out_buf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }

+ 2 - 2
src/lib/dhcp/tests/option_int_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012,2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -41,7 +41,7 @@ public:
     ///
     /// Initializes the option buffer with some data.
     OptionIntTest(): buf_(255), out_buf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }

+ 5 - 5
src/lib/dhcp/tests/option_unittest.cc

@@ -102,7 +102,7 @@ public:
 class OptionTest : public ::testing::Test {
 public:
     OptionTest(): buf_(255), outBuf_(255) {
-        for (int i = 0; i < 255; i++) {
+        for (unsigned i = 0; i < 255; i++) {
             buf_[i] = 255 - i;
         }
     }
@@ -251,7 +251,7 @@ TEST_F(OptionTest, v6_basic) {
 
 // Tests constructor used in packet reception.  Option contains actual data
 TEST_F(OptionTest, v6_data1) {
-    for (int i = 0; i < 32; i++) {
+    for (unsigned i = 0; i < 32; i++) {
         buf_[i] = 100 + i;
     }
 
@@ -324,7 +324,7 @@ TEST_F(OptionTest, v6_data2) {
 //  +----opt3
 //
 TEST_F(OptionTest, v6_suboptions1) {
-    for (int i = 0; i < 128; i++) {
+    for (unsigned i = 0; i < 128; i++) {
         buf_[i] = 100 + i;
     }
 
@@ -367,7 +367,7 @@ TEST_F(OptionTest, v6_suboptions1) {
 //        +----opt3
 //
 TEST_F(OptionTest, v6_suboptions2) {
-    for (int i = 0; i < 128; i++) {
+    for (unsigned i = 0; i < 128; i++) {
         buf_[i] = 100 + i;
     }
 
@@ -399,7 +399,7 @@ TEST_F(OptionTest, v6_suboptions2) {
 }
 
 TEST_F(OptionTest, v6_addgetdel) {
-    for (int i = 0; i < 128; i++) {
+    for (unsigned i = 0; i < 128; i++) {
         buf_[i] = 100 + i;
     }
 

+ 15 - 15
src/lib/dhcp/tests/pkt4_unittest.cc

@@ -277,7 +277,7 @@ TEST_F(Pkt4Test, constructor) {
 
     // Just some dummy payload.
     uint8_t testData[250];
-    for (int i = 0; i < 250; i++) {
+    for (uint8_t i = 0; i < 250; i++) {
         testData[i] = i;
     }
 
@@ -415,12 +415,12 @@ TEST_F(Pkt4Test, hwAddr) {
 
     scoped_ptr<Pkt4> pkt;
     // let's test each hlen, from 0 till 16
-    for (int macLen = 0; macLen < Pkt4::MAX_CHADDR_LEN; macLen++) {
-        for (int i = 0; i < Pkt4::MAX_CHADDR_LEN; i++) {
+    for (size_t macLen = 0; macLen < Pkt4::MAX_CHADDR_LEN; macLen++) {
+        for (size_t i = 0; i < Pkt4::MAX_CHADDR_LEN; i++) {
             mac[i] = 0;
             expectedChaddr[i] = 0;
         }
-        for (int i = 0; i < macLen; i++) {
+        for (size_t i = 0; i < macLen; i++) {
             mac[i] = 128 + i;
             expectedChaddr[i] = 128 + i;
         }
@@ -473,7 +473,7 @@ TEST_F(Pkt4Test, msgTypes) {
     };
 
     scoped_ptr<Pkt4> pkt;
-    for (int i = 0; i < sizeof(types) / sizeof(msgType); i++) {
+    for (size_t i = 0; i < sizeof(types) / sizeof(msgType); i++) {
         pkt.reset(new Pkt4(types[i].dhcp, 0));
         EXPECT_EQ(types[i].dhcp, pkt->getType());
         EXPECT_EQ(types[i].bootp, pkt->getOp());
@@ -493,11 +493,11 @@ TEST_F(Pkt4Test, sname) {
 
     scoped_ptr<Pkt4> pkt;
     // Let's test each sname length, from 0 till 64
-    for (int snameLen = 0; snameLen < Pkt4::MAX_SNAME_LEN; ++snameLen) {
-        for (int i = 0; i < snameLen; ++i) {
+    for (size_t snameLen = 0; snameLen < Pkt4::MAX_SNAME_LEN; ++snameLen) {
+        for (size_t i = 0; i < snameLen; ++i) {
             sname[i] = i + 1;
         }
-        for (int i = snameLen; i < Pkt4::MAX_SNAME_LEN; ++i) {
+        for (size_t i = snameLen; i < Pkt4::MAX_SNAME_LEN; ++i) {
             sname[i] = 0;
         }
 
@@ -531,11 +531,11 @@ TEST_F(Pkt4Test, file) {
 
     scoped_ptr<Pkt4> pkt;
     // Let's test each file length, from 0 till 128.
-    for (int fileLen = 0; fileLen < Pkt4::MAX_FILE_LEN; ++fileLen) {
-        for (int i = 0; i < fileLen; ++i) {
+    for (size_t fileLen = 0; fileLen < Pkt4::MAX_FILE_LEN; ++fileLen) {
+        for (size_t i = 0; i < fileLen; ++i) {
             file[i] = i + 1;
         }
-        for (int i = fileLen; i < Pkt4::MAX_FILE_LEN; ++i) {
+        for (size_t i = fileLen; i < Pkt4::MAX_FILE_LEN; ++i) {
             file[i] = 0;
         }
 
@@ -567,7 +567,7 @@ TEST_F(Pkt4Test, options) {
     scoped_ptr<Pkt4> pkt(new Pkt4(DHCPOFFER, 0));
 
     vector<uint8_t> payload[5];
-    for (int i = 0; i < 5; i++) {
+    for (uint8_t i = 0; i < 5; i++) {
         payload[i].push_back(i * 10);
         payload[i].push_back(i * 10 + 1);
         payload[i].push_back(i * 10 + 2);
@@ -638,7 +638,7 @@ TEST_F(Pkt4Test, unpackOptions) {
     expectedFormat.push_back(0x53);
     expectedFormat.push_back(0x63);
 
-    for (int i = 0; i < sizeof(v4_opts); i++) {
+    for (size_t i = 0; i < sizeof(v4_opts); i++) {
         expectedFormat.push_back(v4_opts[i]);
     }
 
@@ -664,7 +664,7 @@ TEST_F(Pkt4Test, unpackOptionsWithCallback) {
     expectedFormat.push_back(0x53);
     expectedFormat.push_back(0x63);
 
-    for (int i = 0; i < sizeof(v4_opts); i++) {
+    for (size_t i = 0; i < sizeof(v4_opts); i++) {
         expectedFormat.push_back(v4_opts[i]);
     }
 
@@ -904,7 +904,7 @@ TEST_F(Pkt4Test, getLabel) {
 
     // Add a client id to the packet then verify getLabel
     OptionBuffer clnt_id(4);
-    for (int i = 0; i < 4; i++) {
+    for (uint8_t i = 0; i < 4; i++) {
         clnt_id[i] = 100 + i;
     }
 

+ 1 - 1
src/lib/dhcp/tests/pkt6_unittest.cc

@@ -505,7 +505,7 @@ TEST_F(Pkt6Test, Timestamp) {
 // packet type names.
 TEST_F(Pkt6Test, getName) {
     // Check all possible packet types
-    for (int itype = 0; itype < 256; ++itype) {
+    for (unsigned itype = 0; itype < 256; ++itype) {
         uint8_t type = itype;
 
         switch (type) {

+ 3 - 3
src/lib/dhcp/tests/protocol_util_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -247,12 +247,12 @@ TEST(ProtocolUtilTest, writeEthernetHeader) {
     // get exact values that are mismatched. If memcmp was used
     // the error message would not indicate the values of
     // mismatched bytes.
-    for (int i = 0; i < 6; ++i) {
+    for (unsigned i = 0; i < 6; ++i) {
         EXPECT_EQ(dest_hw_addr[i], buf[i]);
     }
     // Verify that following 6 bytes comprise the valid source
     // HW address.
-    for (int i = 0; i < 6; ++i) {
+    for (unsigned i = 0; i < 6; ++i) {
         EXPECT_EQ(src_hw_addr[i], buf[i + 6]);
     }
 

+ 1 - 1
src/lib/dhcpsrv/parsers/dhcp_parsers.cc

@@ -254,7 +254,7 @@ HooksLibrariesParser::build(ConstElementPtr value) {
 
         // Construct the list of libraries in error for the message.
         string error_list = error_libs[0];
-        for (int i = 1; i < error_libs.size(); ++i) {
+        for (size_t i = 1; i < error_libs.size(); ++i) {
             error_list += (string(", ") + error_libs[i]);
         }
         isc_throw(DhcpConfigError, "hooks libraries failed to validate - "

+ 11 - 11
src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc

@@ -65,7 +65,7 @@ CfgHostsTest::CfgHostsTest() {
     const uint8_t mac_template[] = {
         0x01, 0x02, 0x0A, 0xBB, 0x03, 0x00
     };
-    for (int i = 0; i < 50; ++i) {
+    for (unsigned i = 0; i < 50; ++i) {
         std::vector<uint8_t> vec(mac_template,
                                  mac_template + sizeof(mac_template));
         vec[vec.size() - 1] = i;
@@ -76,7 +76,7 @@ CfgHostsTest::CfgHostsTest() {
     const uint8_t duid_template[] = {
         0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x00
     };
-    for (int i = 0; i < 50; ++i) {
+    for (unsigned i = 0; i < 50; ++i) {
         std::vector<uint8_t> vec(duid_template,
                                  duid_template + sizeof(mac_template));
         vec[vec.size() - 1] = i;
@@ -238,7 +238,7 @@ TEST_F(CfgHostsTest, getAll4ByAddress) {
 TEST_F(CfgHostsTest, get4) {
     CfgHosts cfg;
     // Add hosts.
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
         // Add host identified by HW address.
         cfg.add(HostPtr(new Host(hwaddrs_[i]->toText(false),
                                  "hw-address",
@@ -251,7 +251,7 @@ TEST_F(CfgHostsTest, get4) {
                                  increase(IOAddress("192.0.2.100"), i))));
     }
 
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
         // Retrieve host by HW address. The DUID is non-null but there is no
         // reservation made for the DUID so the reservation is returned for
         // HW address.
@@ -284,7 +284,7 @@ TEST_F(CfgHostsTest, get4) {
 TEST_F(CfgHostsTest, get6) {
     CfgHosts cfg;
     // Add hosts.
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
         // Add host identified by HW address.
         HostPtr host = HostPtr(new Host(hwaddrs_[i]->toText(false),
                                         "hw-address",
@@ -305,7 +305,7 @@ TEST_F(CfgHostsTest, get6) {
         cfg.add(host);
     }
 
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
         // Retrieve host by HW address. The DUID is non-null but there is no
         // reservation made for the DUID so the reservation is returned for
         // HW address.
@@ -342,7 +342,7 @@ TEST_F(CfgHostsTest, get6) {
 TEST_F(CfgHostsTest, get6ByAddr) {
     CfgHosts cfg;
     // Add hosts.
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
 
         // Add host identified by DUID.
         HostPtr host = HostPtr(new Host(duids_[i]->toText(), "duid",
@@ -354,7 +354,7 @@ TEST_F(CfgHostsTest, get6ByAddr) {
         cfg.add(host);
     }
 
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
         // Retrieve host by (subnet-id,address).
         HostPtr host = cfg.get6(SubnetID(1 + i % 2),
                                 increase(IOAddress("2001:db8:2::1"), i));
@@ -375,7 +375,7 @@ TEST_F(CfgHostsTest, get6MultipleAddrs) {
     CfgHosts cfg;
 
     // Add 25 hosts. Each host has reservations for 5 addresses.
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
 
         // Add host identified by DUID.
         HostPtr host = HostPtr(new Host(duids_[i]->toText(), "duid",
@@ -396,13 +396,13 @@ TEST_F(CfgHostsTest, get6MultipleAddrs) {
 
     // Now check if we can retrieve each of those 25 hosts by using each
     // of their addresses.
-    for (int i = 0; i < 25; ++i) {
+    for (unsigned i = 0; i < 25; ++i) {
 
         // Check that the host is there.
         HostPtr by_duid = cfg.get6(SubnetID(1 + i % 2), duids_[i], hwaddr_not_used);
         ASSERT_TRUE(by_duid);
 
-        for (int j = 0; j < 5; ++j) {
+        for (unsigned j = 0; j < 5; ++j) {
             std::stringstream tmp;
             tmp << "2001:db8:" << i << "::" << j;
 

+ 3 - 3
src/lib/dhcpsrv/tests/d2_udp_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -431,7 +431,7 @@ TEST_F(D2ClientMgrTest, ifaceRegister) {
     ASSERT_NO_THROW(startSender(getErrorHandler()));
 
     // Queue three messages.
-    for (int i = 0; i < 3; ++i) {
+    for (unsigned i = 0; i < 3; ++i) {
         dhcp_ddns::NameChangeRequestPtr ncr = buildTestNcr();
         ASSERT_NO_THROW(sendRequest(ncr));
     }
@@ -472,7 +472,7 @@ TEST_F(D2ClientMgrTest, udpSuspendUpdates) {
     ASSERT_NO_THROW(startSender(getErrorHandler()));
 
     // Send a test request.
-    for (int i = 0; i < 3; ++i) {
+    for (unsigned i = 0; i < 3; ++i) {
         dhcp_ddns::NameChangeRequestPtr ncr = buildTestNcr();
         ASSERT_NO_THROW(sendRequest(ncr));
     }

+ 12 - 12
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc

@@ -335,13 +335,13 @@ template <typename T>
 void GenericLeaseMgrTest::checkLeasesDifferent(const std::vector<T>& leases) const {
 
     // Check they were created
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         ASSERT_TRUE(leases[i]);
     }
 
     // Check they are different
-    for (int i = 0; i < (leases.size() - 1); ++i) {
-        for (int j = (i + 1); j < leases.size(); ++j) {
+    for (size_t i = 0; i < (leases.size() - 1); ++i) {
+        for (size_t j = (i + 1); j < leases.size(); ++j) {
             stringstream s;
             s << "Comparing leases " << i << " & " << j << " for equality";
             SCOPED_TRACE(s.str());
@@ -355,7 +355,7 @@ GenericLeaseMgrTest::createLeases4() {
 
     // Create leases for each address
     vector<Lease4Ptr> leases;
-    for (int i = 0; i < straddress4_.size(); ++i) {
+    for (size_t i = 0; i < straddress4_.size(); ++i) {
         leases.push_back(initializeLease4(straddress4_[i]));
     }
     EXPECT_EQ(8, leases.size());
@@ -371,7 +371,7 @@ GenericLeaseMgrTest::createLeases6() {
 
     // Create leases for each address
     vector<Lease6Ptr> leases;
-    for (int i = 0; i < straddress6_.size(); ++i) {
+    for (size_t i = 0; i < straddress6_.size(); ++i) {
         leases.push_back(initializeLease6(straddress6_[i]));
     }
     EXPECT_EQ(8, leases.size());
@@ -525,7 +525,7 @@ void
 GenericLeaseMgrTest::testGetLease4HWAddr2() {
     // Get the leases to be used for the test and add to the database
     vector<Lease4Ptr> leases = createLeases4();
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 
@@ -1038,7 +1038,7 @@ void
 GenericLeaseMgrTest::testGetLease4HWAddrSubnetId() {
     // Get the leases to be used for the test and add to the database
     vector<Lease4Ptr> leases = createLeases4();
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 
@@ -1116,7 +1116,7 @@ void
 GenericLeaseMgrTest::testGetLease4ClientId2() {
     // Get the leases to be used for the test and add to the database
     vector<Lease4Ptr> leases = createLeases4();
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 
@@ -1191,7 +1191,7 @@ void
 GenericLeaseMgrTest::testGetLease4ClientIdSubnetId() {
     // Get the leases to be used for the test and add to the database
     vector<Lease4Ptr> leases = createLeases4();
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 
@@ -1228,7 +1228,7 @@ GenericLeaseMgrTest::testGetLeases6DuidIaid() {
     ASSERT_LE(6, leases.size());    // Expect to access leases 0 through 5
 
     // Add them to the database
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 
@@ -1391,7 +1391,7 @@ void
 GenericLeaseMgrTest::testGetLease6DuidIaidSubnetId() {
     // Get the leases to be used for the test and add them to the database.
     vector<Lease6Ptr> leases = createLeases6();
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 
@@ -1457,7 +1457,7 @@ void
 GenericLeaseMgrTest::testUpdateLease4() {
     // Get the leases to be used for the test and add them to the database.
     vector<Lease4Ptr> leases = createLeases4();
-    for (int i = 0; i < leases.size(); ++i) {
+    for (size_t i = 0; i < leases.size(); ++i) {
         EXPECT_TRUE(lmptr_->addLease(leases[i]));
     }
 

+ 3 - 3
src/lib/dhcpsrv/tests/host_mgr_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -62,7 +62,7 @@ HostMgrTest::SetUp() {
     const uint8_t mac_template[] = {
         0x01, 0x02, 0x0A, 0xBB, 0x03, 0x00
     };
-    for (int i = 0; i < 10; ++i) {
+    for (uint8_t i = 0; i < 10; ++i) {
         std::vector<uint8_t> vec(mac_template,
                                  mac_template + sizeof(mac_template));
         vec[vec.size() - 1] = i;
@@ -73,7 +73,7 @@ HostMgrTest::SetUp() {
     const uint8_t duid_template[] = {
         0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x00
     };
-    for (int i = 0; i < 10; ++i) {
+    for (uint8_t i = 0; i < 10; ++i) {
         std::vector<uint8_t> vec(duid_template,
                                  duid_template + sizeof(mac_template));
         vec[vec.size() - 1] = i;

+ 2 - 2
src/lib/dns/master_loader.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -821,7 +821,7 @@ MasterLoader::MasterLoaderImpl::doGenerate() {
     }
 
     // Generate and add the records.
-    for (int i = start; i <= stop; i += step) {
+    for (unsigned int i = start; i <= stop; i += step) {
         // Get generated strings for LHS and RHS. LHS goes to form the
         // name, RHS goes to form the RDATA of the RR.
         const std::string generated_name = generateForIter(lhs, i);

+ 2 - 2
src/lib/dns/tests/rdata_sshfp_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2013  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013, 2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -257,7 +257,7 @@ TEST_F(Rdata_SSHFP_Test, getFingerprint) {
 
     EXPECT_EQ(rdata_sshfp.getFingerprintLength(),
               fingerprint.size());
-    for (int i = 0; i < fingerprint.size(); ++i) {
+    for (size_t i = 0; i < fingerprint.size(); ++i) {
         EXPECT_EQ(rdata_sshfp_wiredata[i + 2],
                   fingerprint.at(i));
     }

+ 5 - 3
src/lib/dns/tests/zone_checker_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -79,7 +79,8 @@ protected:
     // the caller can check other cases.
     void checkIssues() {
         EXPECT_EQ(expected_errors_.size(), errors_.size());
-        for (int i = 0; i < std::min(expected_errors_.size(), errors_.size());
+        for (size_t i = 0;
+             i < std::min(expected_errors_.size(), errors_.size());
              ++i) {
             // The actual message should begin with the expected message.
             EXPECT_EQ(0, errors_[0].find(expected_errors_[0]))
@@ -87,7 +88,8 @@ protected:
                 expected_errors_[0];
         }
         EXPECT_EQ(expected_warns_.size(), warns_.size());
-        for (int i = 0; i < std::min(expected_warns_.size(), warns_.size());
+        for (size_t i = 0;
+             i < std::min(expected_warns_.size(), warns_.size());
              ++i) {
             EXPECT_EQ(0, warns_[0].find(expected_warns_[0]))
                 << "actual message: " << warns_[0] << " expected: " <<

+ 3 - 3
src/lib/hooks/library_manager.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013,2015  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013, 2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -150,7 +150,7 @@ LibraryManager::registerStandardCallouts() {
 
     // Iterate through the list of known hooks
     vector<string> hook_names = ServerHooks::getServerHooks().getHookNames();
-    for (int i = 0; i < hook_names.size(); ++i) {
+    for (size_t i = 0; i < hook_names.size(); ++i) {
 
         // Look up the symbol
         void* dlsym_ptr = dlsym(dl_handle_, hook_names[i].c_str());
@@ -334,7 +334,7 @@ LibraryManager::unloadLibrary() {
         // library on all hooks.
         vector<string> hooks = ServerHooks::getServerHooks().getHookNames();
         manager_->setLibraryIndex(index_);
-        for (int i = 0; i < hooks.size(); ++i) {
+        for (size_t i = 0; i < hooks.size(); ++i) {
             bool removed = manager_->deregisterAllCallouts(hooks[i]);
             if (removed) {
                 LOG_DEBUG(hooks_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUTS_REMOVED)

+ 2 - 2
src/lib/hooks/library_manager_collection.cc

@@ -63,7 +63,7 @@ LibraryManagerCollection::loadLibraries() {
     callout_manager_.reset(new CalloutManager(library_names_.size()));
 
     // Now iterate through the libraries are load them one by one.  We'll
-    for (int i = 0; i < library_names_.size(); ++i) {
+    for (size_t i = 0; i < library_names_.size(); ++i) {
         // Create a pointer to the new library manager.  The index of this
         // library is determined by the number of library managers currently
         // loaded: note that the library indexes run from 1 to (number of loaded
@@ -116,7 +116,7 @@ LibraryManagerCollection::validateLibraries(
                           const std::vector<std::string>& libraries) {
 
     std::vector<std::string> failures;
-    for (int i = 0; i < libraries.size(); ++i) {
+    for (size_t i = 0; i < libraries.size(); ++i) {
         if (!LibraryManager::validateLibrary(libraries[i])) {
             failures.push_back(libraries[i]);
         }

+ 2 - 2
src/lib/hooks/tests/server_hooks_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013, 2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -88,7 +88,7 @@ TEST(ServerHooksTest, GetHookNames) {
     expected_names.push_back("beta");
     expected_names.push_back("gamma");
     expected_names.push_back("delta");
-    for (int i = 0; i < expected_names.size(); ++i) {
+    for (size_t i = 0; i < expected_names.size(); ++i) {
         hooks.registerHook(expected_names[i].c_str());
     };
 

+ 5 - 5
src/lib/util/csv_file.cc

@@ -49,7 +49,7 @@ CSVRow::readAt(const size_t at) const {
 std::string
 CSVRow::render() const {
     std::ostringstream s;
-    for (int i = 0; i < values_.size(); ++i) {
+    for (size_t i = 0; i < values_.size(); ++i) {
         // Do not put separator before the first value.
         if (i > 0) {
             s << separator_;
@@ -203,9 +203,9 @@ CSVFile::size() const {
 
 int
 CSVFile::getColumnIndex(const std::string& col_name) const {
-    for (int i = 0; i < cols_.size(); ++i) {
+    for (size_t i = 0; i < cols_.size(); ++i) {
         if (cols_[i] == col_name) {
-            return (i);
+            return (static_cast<int>(i));
         }
     }
     return (-1);
@@ -347,7 +347,7 @@ CSVFile::recreate() {
     // Opened successfully. Write a header to it.
     try {
         CSVRow header(getColumnCount());
-        for (int i = 0; i < getColumnCount(); ++i) {
+        for (size_t i = 0; i < getColumnCount(); ++i) {
             header.writeAt(i, getColumnName(i));
         }
         *fs_ << header << std::endl;
@@ -383,7 +383,7 @@ CSVFile::validateHeader(const CSVRow& header) {
         return (false);
     }
 
-    for (int i = 0; i < getColumnCount(); ++i) {
+    for (size_t i = 0; i < getColumnCount(); ++i) {
         if (getColumnName(i) != header.readAt(i)) {
             return (false);
         }