Minor code clean-up for GCC 4.9.
- Tidy up "signed vs unsigned" comparison
- Unconditionally initialize the "protocol" variable. This is a
false-positive warning as protocol is indeed initialized when used,
but GCC failed to detect the dependency between protocol and ip6.
Change-Id: I8146898d91d45531c3de73403e0df3330c0a2043
diff --git a/clatd_test.cpp b/clatd_test.cpp
index ba78898..5172d3f 100644
--- a/clatd_test.cpp
+++ b/clatd_test.cpp
@@ -286,8 +286,8 @@
uint8_t *reassembled, size_t *reassembled_len, const char *msg) {
struct iphdr *ip = NULL;
struct ip6_hdr *ip6 = NULL;
- int total_length, pos = 0;
- uint8_t protocol;
+ size_t total_length, pos = 0;
+ uint8_t protocol = 0;
uint8_t version = ip_version(fragments[0]);
for (int i = 0; i < numpackets; i++) {
@@ -345,7 +345,7 @@
// Copy the payload.
int payload_length = len - payload_offset;
total_length += payload_length;
- ASSERT_LT(total_length, (int) *reassembled_len) << msg << ": Reassembly buffer too small\n";
+ ASSERT_LT(total_length, *reassembled_len) << msg << ": Reassembly buffer too small\n";
memcpy(reassembled + pos, packet + payload_offset, payload_length);
pos += payload_length;
}
@@ -596,8 +596,8 @@
uint32_t ipv6_pseudo_sum = ipv6_pseudo_header_checksum((struct ip6_hdr *) ip6, UDP_LEN,
IPPROTO_UDP);
- EXPECT_EQ(0x3ad0, ipv4_pseudo_sum) << "IPv4 pseudo-checksum sanity check\n";
- EXPECT_EQ(0x2644b, ipv6_pseudo_sum) << "IPv6 pseudo-checksum sanity check\n";
+ EXPECT_EQ(0x3ad0U, ipv4_pseudo_sum) << "IPv4 pseudo-checksum sanity check\n";
+ EXPECT_EQ(0x2644bU, ipv6_pseudo_sum) << "IPv6 pseudo-checksum sanity check\n";
EXPECT_EQ(
kUdpV4Checksum,
ip_checksum_finish(ipv4_pseudo_sum + kUdpPartialChecksum + kPayloadPartialChecksum))