Browse Source

[3833] fixed signed for variables in src/bin

Francis Dupont 10 years ago
parent
commit
71e3c3c92f

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

@@ -438,7 +438,7 @@ TEST_F(Dhcpv4SrvTest, processDecline) {
 
 TEST_F(Dhcpv4SrvTest, serverReceivedPacketName) {
     // 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) {
@@ -3511,7 +3511,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;
     }
@@ -3529,7 +3529,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
@@ -220,7 +220,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;
     }
 
@@ -234,7 +234,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)));
@@ -427,12 +427,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

@@ -172,7 +172,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
@@ -384,7 +384,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

@@ -2114,7 +2114,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.