Parcourir la source

[1540] Small formatting corrections

... and a change to get the unit test to compile correctly.
Stephen Morris il y a 13 ans
Parent
commit
b8ccce76ca

+ 8 - 8
src/lib/dhcp/iface_mgr.cc

@@ -894,11 +894,11 @@ Pkt6Ptr IfaceMgr::receive6() {
         return (Pkt6Ptr()); // NULL
     }
 
-    pkt->setLocalAddr(IOAddress::from_bytes(AF_INET6, reinterpret_cast<const uint8_t*>(&to_addr)));
-    pkt->setRemoteAddr(IOAddress::from_bytes(AF_INET6, reinterpret_cast<const uint8_t*>(&from.sin6_addr)));
-
+    pkt->setLocalAddr(IOAddress::from_bytes(AF_INET6,
+                      reinterpret_cast<const uint8_t*>(&to_addr)));
+    pkt->setRemoteAddr(IOAddress::from_bytes(AF_INET6,
+                       reinterpret_cast<const uint8_t*>(&from.sin6_addr)));
     pkt->setRemotePort(ntohs(from.sin6_port));
-
     pkt->setIndex(ifindex);
 
     Iface* received = getIface(pkt->getIndex());
@@ -922,15 +922,15 @@ Pkt6Ptr IfaceMgr::receive6() {
 
 uint16_t IfaceMgr::getSocket(const isc::dhcp::Pkt6& pkt) {
     Iface* iface = getIface(pkt.getIface());
-    if (!iface) {
+    if (iface == NULL) {
         isc_throw(BadValue, "Tried to find socket for non-existent interface "
                   << pkt.getIface());
     }
 
     SocketCollection::const_iterator s;
     for (s = iface->sockets_.begin(); s != iface->sockets_.end(); ++s) {
-        if ( (s->family_ == AF_INET6) &&
-             (!s->addr_.getAddress().to_v6().is_multicast()) ) {
+        if ((s->family_ == AF_INET6) &&
+            (!s->addr_.getAddress().to_v6().is_multicast())) {
             return (s->sockfd_);
         }
         /// @todo: Add more checks here later. If remote address is
@@ -944,7 +944,7 @@ uint16_t IfaceMgr::getSocket(const isc::dhcp::Pkt6& pkt) {
 
 uint16_t IfaceMgr::getSocket(isc::dhcp::Pkt4 const& pkt) {
     Iface* iface = getIface(pkt.getIface());
-    if (!iface) {
+    if (iface == NULL) {
         isc_throw(BadValue, "Tried to find socket for non-existent interface "
                   << pkt.getIface());
     }

+ 2 - 2
src/lib/dhcp/iface_mgr.h

@@ -456,7 +456,7 @@ protected:
     /// @param control_buf_len buffer length
     /// @param pkt packet to be sent
     void os_send4(struct msghdr& m, boost::scoped_array<char>& control_buf,
-                        size_t control_buf_len, const Pkt4Ptr& pkt);
+                  size_t control_buf_len, const Pkt4Ptr& pkt);
 
     /// @brief OS-specific operations during IPv4 packet reception
     ///
@@ -468,7 +468,7 @@ protected:
 
 private:
 
-    /// creates a single instance of this class (a singleton implementation)
+    /// @brief Creates a single instance of this class (a singleton implementation)
     static void
     instanceCreate();
 

+ 5 - 3
src/lib/util/range_utilities.h

@@ -15,6 +15,7 @@
 #ifndef __RANGE_UTIL_H_
 #define __RANGE_UTIL_H_ 1
 
+#include <cstdlib>
 #include <algorithm>
 
 // This header contains useful methods for conduction operations on
@@ -54,9 +55,10 @@ isRangeZero(Iterator begin, Iterator end) {
 /// @param begin
 /// @param end
 template <typename Iterator>
-void fillRandom(Iterator begin, Iterator end) {
-    for (Iterator x=begin; x != end; ++x) {
-        *x = rand();
+void
+fillRandom(Iterator begin, Iterator end) {
+    for (Iterator x = begin; x != end; ++x) {
+        *x = std::rand();
     }
 }
 

+ 1 - 1
src/lib/util/tests/buffer_unittest.cc

@@ -283,7 +283,7 @@ TEST_F(BufferTest, inputBufferConstructorVector) {
 
     std::vector<uint8_t> vec2;
     EXPECT_NO_THROW(buf.readVector(vec2, 17));
-    EXPECT_EQ(vec, vec2);
+    EXPECT_TRUE(vec == vec2);
 }
 
 }