Add type cast to fix build error with "-Wsign-compare" cflag.
There is build error if "-Wsign-compare" is defined in cflags.
Also add "-Wsign-compare" to Android.bp
Test: Build
Change-Id: If41da96ec521a0d2dcddf660e7effa218c99810d
Signed-off-by: Sehee Park <sehee32.park@samsung.com>
diff --git a/libnetdutils/InternetAddressesTest.cpp b/libnetdutils/InternetAddressesTest.cpp
index c63ecc5..59d8210 100644
--- a/libnetdutils/InternetAddressesTest.cpp
+++ b/libnetdutils/InternetAddressesTest.cpp
@@ -130,12 +130,12 @@
TEST(IPAddressTest, ScopeIds) {
// Scope IDs ignored for IPv4 addresses.
const IPAddress ones(IPV4_ONES);
- EXPECT_EQ(0, ones.scope_id());
+ EXPECT_EQ(0U, ones.scope_id());
const IPAddress ones22(ones, 22);
- EXPECT_EQ(0, ones22.scope_id());
+ EXPECT_EQ(0U, ones22.scope_id());
EXPECT_EQ(ones, ones22);
const IPAddress ones23(ones, 23);
- EXPECT_EQ(0, ones23.scope_id());
+ EXPECT_EQ(0U, ones23.scope_id());
EXPECT_EQ(ones22, ones23);
EXPECT_EQ("fe80::1%22", IPAddress(FE80_1, 22).toString());
@@ -144,7 +144,7 @@
// Verify that given an IPAddress with a scope_id an address without a
// scope_id can be constructed (just in case it's useful).
const IPAddress fe80_intf22(FE80_1, 22);
- EXPECT_EQ(22, fe80_intf22.scope_id());
+ EXPECT_EQ(22U, fe80_intf22.scope_id());
EXPECT_EQ(fe80_intf22, IPAddress(fe80_intf22));
EXPECT_EQ(IPAddress(FE80_1), IPAddress(fe80_intf22, 0));
}
@@ -384,7 +384,7 @@
};
int totalTests = 0;
- for (int i = 0; i < arraysize(testExpectations); i++, totalTests++) {
+ for (unsigned int i = 0; i < arraysize(testExpectations); i++, totalTests++) {
IPAddress ip;
EXPECT_TRUE(IPAddress::forString(testExpectations[i].ip, &ip))
<< "Failed to parse IP address " << testExpectations[i].ip;
@@ -400,7 +400,7 @@
EXPECT_EQ(ipTruncated, prefix.ip())
<< "Unexpected IP truncation: " << prefix.ip() << ", expected: " << ipTruncated;
}
- EXPECT_EQ(arraysize(testExpectations), totalTests);
+ EXPECT_EQ(static_cast<int>(arraysize(testExpectations)), totalTests);
}
TEST(IPPrefixTest, GamutOfOperators) {