From: Marcin Siodelski Date: Tue, 23 Oct 2012 18:06:52 +0000 (+0200) Subject: [master] Remove narrowing conversion from int to uint8_t. X-Git-Tag: trac2402_base~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebdd232061e3d9ced4660541cd3ad1c2ca8ed645;p=thirdparty%2Fkea.git [master] Remove narrowing conversion from int to uint8_t. This fix eliminates build failure on Fedora17 and Debian7. Okayed on jabber. --- diff --git a/src/lib/dhcp/tests/option6_int_unittest.cc b/src/lib/dhcp/tests/option6_int_unittest.cc index 2aceed8a7d..3d39a1ae44 100644 --- a/src/lib/dhcp/tests/option6_int_unittest.cc +++ b/src/lib/dhcp/tests/option6_int_unittest.cc @@ -303,7 +303,9 @@ TEST_F(Option6IntTest, setValueint32) { } TEST_F(Option6IntTest, packSuboptions) { - uint16_t opt_code = 80; + // option code is really uint16_t, but using uint8_t + // for easier conversion to uint8_t array. + uint8_t opt_code = 80; boost::shared_ptr > opt(new Option6Int(opt_code, 0x01020304)); OptionPtr sub1(new Option(Option::V6, 0xcafe)); @@ -319,7 +321,7 @@ TEST_F(Option6IntTest, packSuboptions) { ASSERT_EQ(40, opt->len()); uint8_t expected[] = { - opt_code / 256, opt_code % 256, // type + 0, opt_code, // type 0, 36, // length 0x01, 0x02, 0x03, 0x04, // uint32_t value @@ -345,11 +347,12 @@ TEST_F(Option6IntTest, packSuboptions) { TEST_F(Option6IntTest, unpackSuboptions) { - // Create some dummy option. - const uint16_t opt_code = 80; + // option code is really uint16_t, but using uint8_t + // for easier conversion to uint8_t array. + const uint8_t opt_code = 80; // Prepare reference data. uint8_t expected[] = { - opt_code / 256, opt_code % 256, // type + 0, opt_code, // type 0, 34, // length 0x01, 0x02, // uint16_t value