From f28b162ad420491ebad420e25ebc2ea112b5f6f0 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Thu, 15 Feb 2024 19:57:19 +0200 Subject: [#3230] addressed review --- src/lib/dhcp/pkt.cc | 6 +++--- src/lib/dhcp/pkt.h | 6 +++--- src/lib/dhcp/pkt_filter_lpf.cc | 2 +- src/lib/dhcp/tests/pkt4_unittest.cc | 5 ++--- src/lib/dhcp/tests/pkt6_unittest.cc | 4 ++-- src/lib/dhcp/tests/pkt_filter6_test_utils.cc | 4 ++-- src/lib/dhcp/tests/pkt_filter_test_utils.cc | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/lib/dhcp/pkt.cc b/src/lib/dhcp/pkt.cc index 4db0a359f4..4f55fb5e6a 100644 --- a/src/lib/dhcp/pkt.cc +++ b/src/lib/dhcp/pkt.cc @@ -345,9 +345,9 @@ Pkt::addPktEvent(const std::string& label, const struct timeval& tv) { ptime Pkt::getPktEventTime(const std::string& label) const { - for (const auto& event : events_) { + for (auto const& event : events_) { if (event.label_ == label) { - return(event.timestamp_); + return (event.timestamp_); } } @@ -369,7 +369,7 @@ Pkt::dumpPktEvents(bool verbose /* = false */) const { bool first_pass = true; boost::posix_time::ptime beg_time; boost::posix_time::ptime prev_time; - for (const auto& event : events_) { + for (auto const& event : events_) { if (!verbose) { oss << (first_pass ? "" : ", ") << event.timestamp_ << " : " << event.label_; } else { diff --git a/src/lib/dhcp/pkt.h b/src/lib/dhcp/pkt.h index a09e875440..7a65bef33e 100644 --- a/src/lib/dhcp/pkt.h +++ b/src/lib/dhcp/pkt.h @@ -100,7 +100,7 @@ public: /// by application. static const std::string RESPONSE_SENT; - /// @brief Constructor + /// @brief Constructor. /// /// @param label string identifying the event. /// @param timestamp time at which the event occurred. @@ -108,14 +108,14 @@ public: : label_(label), timestamp_(timestamp) { } - /// @brief Destructor + /// @brief Destructor. ~PktEvent() = default; /// @brief Fetch the current UTC system time, microsecond precision. /// /// @return ptime containing the microsecond system time. static boost::posix_time::ptime now() { - return(boost::posix_time::microsec_clock::universal_time()); + return (boost::posix_time::microsec_clock::universal_time()); } /// @brief Fetch an empty timestamp, used for logic comparisons diff --git a/src/lib/dhcp/pkt_filter_lpf.cc b/src/lib/dhcp/pkt_filter_lpf.cc index 7b36dc12fe..c58d8290d9 100644 --- a/src/lib/dhcp/pkt_filter_lpf.cc +++ b/src/lib/dhcp/pkt_filter_lpf.cc @@ -396,7 +396,7 @@ PktFilterLPF::receive(Iface& iface, const SocketInfo& socket_info) { struct cmsghdr* cmsg = CMSG_FIRSTHDR(&m); while (cmsg != NULL) { if ((cmsg->cmsg_level == SOL_SOCKET) && - (cmsg->cmsg_type == SCM_TIMESTAMP)) { + (cmsg->cmsg_type == SCM_TIMESTAMP)) { struct timeval cmsg_time; memcpy(&cmsg_time, CMSG_DATA(cmsg), sizeof(cmsg_time)); diff --git a/src/lib/dhcp/tests/pkt4_unittest.cc b/src/lib/dhcp/tests/pkt4_unittest.cc index c9f120eeef..47ca71162f 100644 --- a/src/lib/dhcp/tests/pkt4_unittest.cc +++ b/src/lib/dhcp/tests/pkt4_unittest.cc @@ -1539,7 +1539,7 @@ TEST_F(Pkt4Test, PktEvents) { // Upon creation, the events table should be empty. ASSERT_TRUE(pkt->getPktEvents().empty()); - // An non-existant event should return an empty time. + // An non-existent event should return an empty time. auto event_time = pkt->getPktEventTime(PktEvent::BUFFER_READ); ASSERT_EQ(event_time, PktEvent::EMPTY_TIME()); @@ -1562,7 +1562,7 @@ TEST_F(Pkt4Test, PktEvents) { ASSERT_EQ(event_time, start_time); // Should be able to fetch the list of events. - const auto& events = pkt->getPktEvents(); + auto const& events = pkt->getPktEvents(); ASSERT_FALSE(events.empty()); auto event = events.begin(); ASSERT_EQ((*event).label_, PktEvent::BUFFER_READ); @@ -1591,5 +1591,4 @@ TEST_F(Pkt4Test, PktEvents) { "total elapsed: 00:00:00.000150"); } - } // end of anonymous namespace diff --git a/src/lib/dhcp/tests/pkt6_unittest.cc b/src/lib/dhcp/tests/pkt6_unittest.cc index 562db62077..6b3b1ab902 100644 --- a/src/lib/dhcp/tests/pkt6_unittest.cc +++ b/src/lib/dhcp/tests/pkt6_unittest.cc @@ -2385,7 +2385,7 @@ TEST_F(Pkt6Test, PktEvents) { // Upon creation, the events table should be empty. ASSERT_TRUE(pkt->getPktEvents().empty()); - // An non-existant event should return an empty time. + // An non-existent event should return an empty time. auto event_time = pkt->getPktEventTime(PktEvent::BUFFER_READ); ASSERT_EQ(event_time, PktEvent::EMPTY_TIME()); @@ -2408,7 +2408,7 @@ TEST_F(Pkt6Test, PktEvents) { ASSERT_EQ(event_time, start_time); // Should be able to fetch the list of events. - const auto& events = pkt->getPktEvents(); + auto const& events = pkt->getPktEvents(); ASSERT_FALSE(events.empty()); auto event = events.begin(); ASSERT_EQ((*event).label_, PktEvent::BUFFER_READ); diff --git a/src/lib/dhcp/tests/pkt_filter6_test_utils.cc b/src/lib/dhcp/tests/pkt_filter6_test_utils.cc index a86fc739f9..44ee44de52 100644 --- a/src/lib/dhcp/tests/pkt_filter6_test_utils.cc +++ b/src/lib/dhcp/tests/pkt_filter6_test_utils.cc @@ -174,13 +174,13 @@ PktFilter6Test::testRcvdMessage(const Pkt6Ptr& rcvd_msg) const { void PktFilter6Test::testPktEvents(const PktPtr& msg, ptime start_time, - std::list expected_events) const { + std::list expected_events) const { ASSERT_NE(start_time, PktEvent::EMPTY_TIME()); auto events = msg->getPktEvents(); ASSERT_EQ(events.size(), expected_events.size()); ptime prev_time = start_time; auto expected_event = expected_events.begin(); - for (const auto& event : events) { + for (auto const& event : events) { ASSERT_EQ(event.label_, *expected_event); EXPECT_GE(event.timestamp_, prev_time); ++expected_event; diff --git a/src/lib/dhcp/tests/pkt_filter_test_utils.cc b/src/lib/dhcp/tests/pkt_filter_test_utils.cc index 8c29b0b604..6be7505bd5 100644 --- a/src/lib/dhcp/tests/pkt_filter_test_utils.cc +++ b/src/lib/dhcp/tests/pkt_filter_test_utils.cc @@ -178,7 +178,7 @@ PktFilterTest::testPktEvents(const PktPtr& msg, ptime start_time, ASSERT_EQ(events.size(), expected_events.size()); ptime prev_time = start_time; auto expected_event = expected_events.begin(); - for (const auto& event : events) { + for (auto const& event : events) { ASSERT_EQ(event.label_, *expected_event); EXPECT_GE(event.timestamp_, prev_time); ++expected_event; -- cgit v1.2.3