]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Remove narrowing conversion from int to uint8_t.
authorMarcin Siodelski <marcin@isc.org>
Tue, 23 Oct 2012 18:06:52 +0000 (20:06 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 23 Oct 2012 18:06:52 +0000 (20:06 +0200)
This fix eliminates build failure on Fedora17 and Debian7. Okayed on jabber.

src/lib/dhcp/tests/option6_int_unittest.cc

index 2aceed8a7d8224c1af1ad5c9742e094a892bb8e4..3d39a1ae442a3604f64a73e82aa2a33b1b730929 100644 (file)
@@ -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<Option6Int<uint32_t> > opt(new Option6Int<uint32_t>(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