Commit 2b7e75de authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[2837] Addressed review comments.

parent 02fb3337
......@@ -28,24 +28,17 @@ HWAddr::HWAddr()
}
HWAddr::HWAddr(const uint8_t* hwaddr, size_t len, uint8_t htype)
:htype_(htype) {
if (len > MAX_HWADDR_LEN)
:hwaddr_(hwaddr, hwaddr + len), htype_(htype) {
if (len > MAX_HWADDR_LEN) {
isc_throw(InvalidParameter, "hwaddr length exceeds MAX_HWADDR_LEN");
hwaddr_.resize(len);
memcpy(&hwaddr_[0], hwaddr, len);
}
}
HWAddr::HWAddr(const std::vector<uint8_t>& hwaddr, uint8_t htype)
:htype_(htype) {
:hwaddr_(hwaddr), htype_(htype) {
if (hwaddr.size() > MAX_HWADDR_LEN)
isc_throw(InvalidParameter,
"address vector size exceeds MAX_HWADDR_LEN");
hwaddr_ = hwaddr;
}
std::string HWAddr::toText() const {
......
......@@ -43,8 +43,7 @@ TEST(HWAddrTest, constructor) {
vector<uint8_t> data2(data1, data1 + sizeof(data1));
// over the limit data
uint8_t big_data[HWAddr::MAX_HWADDR_LEN+1]={0};
vector<uint8_t> big_data_vector(big_data, big_data + sizeof(big_data));
vector<uint8_t> big_data_vector(HWAddr::MAX_HWADDR_LEN + 1, 0);
scoped_ptr<HWAddr> hwaddr1(new HWAddr(data1, sizeof(data1), htype));
scoped_ptr<HWAddr> hwaddr2(new HWAddr(data2, htype));
......@@ -60,7 +59,7 @@ TEST(HWAddrTest, constructor) {
EXPECT_EQ(htype, hwaddr3->htype_);
// check that over the limit data length throws exception
EXPECT_THROW(HWAddr(big_data, sizeof(big_data), HTYPE_ETHER),
EXPECT_THROW(HWAddr(&big_data_vector[0], big_data_vector.size(), HTYPE_ETHER),
InvalidParameter);
// check that over the limit vector throws exception
......
......@@ -1026,7 +1026,7 @@ MySqlLeaseMgr::openDatabase() {
// constitutes insertable data for a given column, and how to handle
// invalid data. We want to ensure we get the strictest behavior and
// to reject invalid data with an error.
const char *sql_mode = "set SESSION sql_mode ='STRICT_ALL_TABLES'";
const char *sql_mode = "SET SESSION sql_mode ='STRICT_ALL_TABLES'";
result = mysql_options(mysql_, MYSQL_INIT_COMMAND, sql_mode);
if (result != 0) {
isc_throw(DbOpenError, "unable to set SQL mode options: " <<
......
......@@ -879,7 +879,9 @@ TEST_F(MySqlLeaseMgrTest, getLease4HwaddrSubnetId) {
EXPECT_TRUE(lmptr_->addLease(leases[1]));
// @todo: Simply use HWAddr directly once 2589 is implemented
EXPECT_THROW(returned = lmptr_->getLease4(HWAddr(leases[1]->hwaddr_,
HTYPE_ETHER), leases[1]->subnet_id_), isc::dhcp::MultipleRecords);
HTYPE_ETHER),
leases[1]->subnet_id_),
isc::dhcp::MultipleRecords);
// Delete all leases in the database
for (int i = 0; ADDRESS4[i] != NULL; ++i) {
......@@ -904,7 +906,8 @@ TEST_F(MySqlLeaseMgrTest, getLease4HwaddrSubnetIdSize) {
EXPECT_TRUE(lmptr_->addLease(leases[1]));
// @todo: Simply use HWAddr directly once 2589 is implemented
Lease4Ptr returned = lmptr_->getLease4(HWAddr(leases[1]->hwaddr_,
HTYPE_ETHER), leases[1]->subnet_id_);
HTYPE_ETHER),
leases[1]->subnet_id_);
ASSERT_TRUE(returned);
detailCompareLease(leases[1], returned);
(void) lmptr_->deleteLease(leases[1]->addr_);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment