From 06c348164df1b825759f1ee6075d70bdbeeae45c Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Tue, 27 Jun 2023 13:23:15 +0300 Subject: [PATCH] [#2942] addressed review coments --- ChangeLog | 2 +- src/lib/dhcp/tests/libdhcp++_unittest.cc | 42 ++++++++++++------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index a124b114ef..e7a840877a 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 #2945, #2942) 2050. [bug] razvan diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc index 85f6ff19b1..0d701e3206 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++; } -- 2.47.2