From: Razvan Becheriu Date: Tue, 27 Jun 2023 10:23:15 +0000 (+0300) Subject: [#2942] addressed review coments X-Git-Tag: Kea-2.4.0~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=903cd2cbbb329ed0547b32c763255489da8efe40;p=thirdparty%2Fkea.git [#2942] addressed review coments --- diff --git a/ChangeLog b/ChangeLog index 4a4a3761ba..fd84d0f1b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ Fixed a crash when splitting long options or sending user defined options when multi-threading is enabled. Also fixed some cases when options are not properly split if the serialized data - reaches the end of the 255 bytes long boundry. + reaches the end of the 255 bytes long boundary. (Gitlab #2942) 2158. [func] piotrek diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc index 33674edd45..ff1811c1e0 100644 --- a/src/lib/dhcp/tests/libdhcp++_unittest.cc +++ b/src/lib/dhcp/tests/libdhcp++_unittest.cc @@ -256,10 +256,10 @@ public: ASSERT_EQ(64, col.size()); uint8_t index = 0; - for (auto const& option : col) { - ASSERT_EQ(option.first, 231); - ASSERT_EQ(1, option.second->getData().size()); - ASSERT_EQ(index, option.second->getData()[0]); + for (auto const& opt : col) { + ASSERT_EQ(opt.first, 231); + ASSERT_EQ(1, opt.second->getData().size()); + ASSERT_EQ(index, opt.second->getData()[0]); index++; } } @@ -301,21 +301,21 @@ public: buf.getLength()); ASSERT_EQ(3, col.size()); - for (auto const& top_subopt : col) { - ASSERT_EQ(top_subopt.second->getType(), 170); + for (auto const& bottom_subopt : col) { + ASSERT_EQ(bottom_subopt.second->getType(), 170); if (opt_count == 0) { // First option contains only data (0..127) and no suboptions. - ASSERT_EQ(top_subopt.second->getData().size(), bottom_size); + ASSERT_EQ(bottom_subopt.second->getData().size(), bottom_size); index = 0; - for (auto const& value : top_subopt.second->getData()) { + for (auto const& value : bottom_subopt.second->getData()) { ASSERT_EQ(value, static_cast(index)); index++; } - ASSERT_EQ(top_subopt.second->getOptions().size(), 0); + ASSERT_EQ(bottom_subopt.second->getOptions().size(), 0); } else { // All other options contain no data and suboption 171. - ASSERT_EQ(top_subopt.second->getOptions().size(), 1); - for (auto const& middle_subopt : top_subopt.second->getOptions()) { + ASSERT_EQ(bottom_subopt.second->getOptions().size(), 1); + for (auto const& middle_subopt : bottom_subopt.second->getOptions()) { ASSERT_EQ(middle_subopt.first, 171); if (opt_count == 1) { // First suboption 171 contains only data (0) and no suboptions. @@ -369,26 +369,26 @@ public: // 2 - third option 170 with suboption 171 with suboption 172 // 3 - suboption 172 opt_count = 0; - for (auto const& top_subopt : col_back) { - ASSERT_EQ(top_subopt.second->getType(), 170); + for (auto const& bottom_subopt : col_back) { + ASSERT_EQ(bottom_subopt.second->getType(), 170); if (opt_count == 0) { // First option contains only data (0..127) and no suboptions. - ASSERT_EQ(top_subopt.second->getData().size(), bottom_size); + ASSERT_EQ(bottom_subopt.second->getData().size(), bottom_size); index = 0; - for (auto const& value : top_subopt.second->getData()) { + for (auto const& value : bottom_subopt.second->getData()) { ASSERT_EQ(value, static_cast(index)); index++; } - ASSERT_EQ(top_subopt.second->getOptions().size(), 0); + ASSERT_EQ(bottom_subopt.second->getOptions().size(), 0); } else { // All other options contain no data and suboption 171. // Using unpackOptions4 will not create suboptions, so entire data is serialized // in the option buffer. - ASSERT_EQ(top_subopt.second->getOptions().size(), 0); + ASSERT_EQ(bottom_subopt.second->getOptions().size(), 0); // 1. and 4. The option 171 code. index = 171; bool data = false; - for (auto const& value : top_subopt.second->getData()) { + for (auto const& value : bottom_subopt.second->getData()) { ASSERT_EQ(value, static_cast(index)); if (index == 171 && opt_count == 1 && !data) { // 2. The option 171 data size (1) - only data. @@ -457,9 +457,9 @@ public: uint32_t index = 0; ASSERT_EQ(11, col_back.size()); - for (auto const& option : col_back) { - ASSERT_EQ(option.first, 231); - for (auto const& value : option.second->getData()) { + for (auto const& opt : col_back) { + ASSERT_EQ(opt.first, 231); + for (auto const& value : opt.second->getData()) { ASSERT_EQ(value, static_cast(index)); index++; }