Browse Source

[3920] Applied proposed cleanup of Pkt{,4} buf/len constructor

Francis Dupont 10 years ago
parent
commit
65c611f281
2 changed files with 6 additions and 5 deletions
  1. 6 2
      src/lib/dhcp/pkt.cc
  2. 0 3
      src/lib/dhcp/pkt4.cc

+ 6 - 2
src/lib/dhcp/pkt.cc

@@ -48,8 +48,12 @@ Pkt::Pkt(const uint8_t* buf, uint32_t len, const isc::asiolink::IOAddress& local
      remote_port_(remote_port),
      buffer_out_(0)
 {
-    data_.resize(len);
-    if (len) {
+
+    if (len != 0) {
+	if (buf == NULL) {
+	    isc_throw(InvalidParameter, "data buffer passed to Pkt is NULL");
+	}
+	data_.resize(len);
         memcpy(&data_[0], buf, len);
     }
 }

+ 0 - 3
src/lib/dhcp/pkt4.cc

@@ -74,9 +74,6 @@ Pkt4::Pkt4(const uint8_t* data, size_t len)
         isc_throw(OutOfRange, "Truncated DHCPv4 packet (len=" << len
                   << ") received, at least " << DHCPV4_PKT_HDR_LEN
                   << " is expected.");
-
-    } else if (data == NULL) {
-        isc_throw(InvalidParameter, "data buffer passed to Pkt4 is NULL");
     }
 }