Parcourir la source

[4319] Addressed some review comments.

- use unsigned int in for loops
- NULL pointer rather than NULL in function descriptions
Marcin Siodelski il y a 9 ans
Parent
commit
8576546a1b

+ 6 - 6
src/bin/dhcp4/tests/config_parser_unittest.cc

@@ -471,7 +471,7 @@ public:
     /// @param option_code Option code.
     /// @tparam ReturnType Type of the pointer object returned.
     ///
-    /// @return Pointer to an option or NULL if not found.
+    /// @return Pointer to an option or NULL pointer if not found.
     template<typename ReturnType>
     ReturnType
     retrieveOption(const Host& host, const uint16_t option_code) const {
@@ -485,7 +485,7 @@ public:
     /// @param option_code Option code.
     /// @tparam ReturnType Type of the pointer object returned.
     ///
-    /// @return Pointer to an option or NULL if not found.
+    /// @return Pointer to an option or NULL pointer if not found.
     template<typename ReturnType>
     ReturnType
     retrieveOption(const Host& host, const std::string& space,
@@ -2911,7 +2911,7 @@ buildHooksLibrariesConfig(const std::vector<std::string>& libraries) {
             "\"hooks-libraries\": [";
 
     // Append the libraries (separated by commas if needed)
-    for (int i = 0; i < libraries.size(); ++i) {
+    for (unsigned int i = 0; i < libraries.size(); ++i) {
         if (i > 0) {
             config += string(", ");
         }
@@ -3483,7 +3483,7 @@ TEST_F(Dhcp4ParserTest, reservations) {
     // a reservation in the subnet having id of 234. For simplicity the
     // address is a collection of numbers from 1 to 6.
     std::vector<uint8_t> hwaddr_vec;
-    for (int i = 1; i < 7; ++i) {
+    for (unsigned int i = 1; i < 7; ++i) {
         hwaddr_vec.push_back(static_cast<uint8_t>(i));
     }
     HWAddrPtr hwaddr(new HWAddr(hwaddr_vec, HTYPE_ETHER));
@@ -3509,7 +3509,7 @@ TEST_F(Dhcp4ParserTest, reservations) {
 
     // Do the same test for the DUID based reservation.
     std::vector<uint8_t> duid_vec;
-    for (int i = 1; i < 0xb; ++i) {
+    for (unsigned int i = 1; i < 0xb; ++i) {
         duid_vec.push_back(static_cast<uint8_t>(i));
     }
     DuidPtr duid(new DUID(duid_vec));
@@ -3608,7 +3608,7 @@ TEST_F(Dhcp4ParserTest, reservationWithOptionDefinition) {
     // Let's create an object holding DUID of the host. For simplicity the
     // address is a collection of numbers from 1 to A.
     std::vector<uint8_t> duid_vec;
-    for (int i = 1; i < 0xB; ++i) {
+    for (unsigned int i = 1; i < 0xB; ++i) {
         duid_vec.push_back(static_cast<uint8_t>(i));
     }
     DuidPtr duid(new DUID(duid_vec));

+ 8 - 8
src/bin/dhcp6/tests/config_parser_unittest.cc

@@ -379,7 +379,7 @@ public:
     /// @param option_code Option code.
     /// @tparam ReturnType Type of the pointer object returned.
     ///
-    /// @return Pointer to an option or NULL if not found.
+    /// @return Pointer to an option or NULL pointer if not found.
     template<typename ReturnType>
     ReturnType
     retrieveOption(const Host& host, const uint16_t option_code) const {
@@ -393,7 +393,7 @@ public:
     /// @param option_code Option code.
     /// @tparam ReturnType Type of the pointer object returned.
     ///
-    /// @return Pointer to an option or NULL if not found.
+    /// @return Pointer to an option or NULL pointer if not found.
     template<typename ReturnType>
     ReturnType
     retrieveOption(const Host& host, const std::string& space,
@@ -1444,7 +1444,7 @@ TEST_F(Dhcp6ParserTest, pdPoolList) {
     EXPECT_EQ(3, pc.size());
 
     // Loop through the pools and verify their contents.
-    for (int i = 0; i < 3; i++) {
+    for (unsigned int i = 0; i < 3; i++) {
         Pool6Ptr p6;
         ASSERT_NO_THROW(p6 = boost::dynamic_pointer_cast<Pool6>(pc[i]));
         ASSERT_TRUE(p6);
@@ -1577,7 +1577,7 @@ TEST_F(Dhcp6ParserTest, invalidPdPools) {
 
     ElementPtr json;
     int num_msgs = sizeof(config)/sizeof(char*);
-    for (int i = 0; i < num_msgs; i++) {
+    for (unsigned int i = 0; i < num_msgs; i++) {
         // Convert JSON string to Elements.
         ASSERT_NO_THROW(json = Element::fromJSON(config[i]));
 
@@ -3065,7 +3065,7 @@ buildHooksLibrariesConfig(const std::vector<std::string>& libraries) {
            "\"hooks-libraries\": [";
 
     // Append the libraries (separated by commas if needed)
-    for (int i = 0; i < libraries.size(); ++i) {
+    for (unsigned int i = 0; i < libraries.size(); ++i) {
         if (i > 0) {
             config += string(", ");
         }
@@ -3615,7 +3615,7 @@ TEST_F(Dhcp6ParserTest, reservations) {
     // a reservation in the subnet having id of 234. For simplicity the
     // address is a collection of numbers from 1 to 6.
     std::vector<uint8_t> hwaddr_vec;
-    for (int i = 1; i < 7; ++i) {
+    for (unsigned int i = 1; i < 7; ++i) {
         hwaddr_vec.push_back(static_cast<uint8_t>(i));
     }
     HWAddrPtr hwaddr(new HWAddr(hwaddr_vec, HTYPE_ETHER));
@@ -3645,7 +3645,7 @@ TEST_F(Dhcp6ParserTest, reservations) {
 
     // Do the same test for the DUID based reservation.
     std::vector<uint8_t> duid_vec;
-    for (int i = 1; i < 0xb; ++i) {
+    for (unsigned int i = 1; i < 0xb; ++i) {
         duid_vec.push_back(static_cast<uint8_t>(i));
     }
     DuidPtr duid(new DUID(duid_vec));
@@ -3761,7 +3761,7 @@ TEST_F(Dhcp6ParserTest, reservationWithOptionDefinition) {
     // Let's create an object holding DUID of the host. For simplicity the
     // address is a collection of numbers from 1 to A.
     std::vector<uint8_t> duid_vec;
-    for (int i = 1; i < 0xB; ++i) {
+    for (unsigned int i = 1; i < 0xB; ++i) {
         duid_vec.push_back(static_cast<uint8_t>(i));
     }
     DuidPtr duid(new DUID(duid_vec));

+ 2 - 2
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc

@@ -65,8 +65,8 @@ protected:
     /// @param option_space Option space name.
     /// @param option_code Code of an option to be retrieved.
     ///
-    /// @return Pointer to the option retrieved or NULL if option hasn't been
-    /// found.
+    /// @return Pointer to the option retrieved or NULL pointer if option
+    /// hasn't been found.
     OptionPtr
     retrieveOption(const Host& host, const std::string& option_space,
                    const uint16_t option_code) const {