Binder: enable/fix some warnings
Bug: 341997808
Test: mma
Change-Id: Ibd44eda768a714e85399a15f3c8e534d715f87ce
Merged-In: Ibd44eda768a714e85399a15f3c8e534d715f87ce
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index 5582a96..9b1ba01 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -47,10 +47,9 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include "../Utils.h"
#include "../binder_module.h"
-#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
-
using namespace android;
using namespace android::binder::impl;
using namespace std::string_literals;
@@ -216,10 +215,9 @@
sp<IServiceManager> sm = defaultServiceManager();
//printf("%s: pid %d, get service\n", __func__, m_pid);
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ LIBBINDER_IGNORE("-Wdeprecated-declarations")
m_server = sm->getService(binderLibTestServiceName);
-#pragma clang diagnostic pop
+ LIBBINDER_IGNORE_END()
ASSERT_TRUE(m_server != nullptr);
//printf("%s: pid %d, get service done\n", __func__, m_pid);
}
@@ -566,7 +564,7 @@
TEST_F(BinderLibTest, SetError) {
int32_t testValue[] = { 0, -123, 123 };
- for (size_t i = 0; i < ARRAY_SIZE(testValue); i++) {
+ for (size_t i = 0; i < countof(testValue); i++) {
Parcel data, reply;
data.writeInt32(testValue[i]);
EXPECT_THAT(m_server->transact(BINDER_LIB_TEST_SET_ERROR_TRANSACTION, data, &reply),
@@ -597,8 +595,8 @@
Parcel data, reply;
int32_t serverId[3];
- data.writeInt32(ARRAY_SIZE(serverId));
- for (size_t i = 0; i < ARRAY_SIZE(serverId); i++) {
+ data.writeInt32(countof(serverId));
+ for (size_t i = 0; i < countof(serverId); i++) {
sp<IBinder> server;
BinderLibTestBundle datai;
@@ -616,7 +614,7 @@
EXPECT_EQ(0, id);
ASSERT_THAT(reply.readInt32(&count), StatusEq(NO_ERROR));
- EXPECT_EQ(ARRAY_SIZE(serverId), (size_t)count);
+ EXPECT_EQ(countof(serverId), (size_t)count);
for (size_t i = 0; i < (size_t)count; i++) {
BinderLibTestBundle replyi(&reply);
@@ -636,8 +634,8 @@
Parcel data, reply;
int32_t serverId[3];
- data.writeInt32(ARRAY_SIZE(serverId));
- for (size_t i = 0; i < ARRAY_SIZE(serverId); i++) {
+ data.writeInt32(countof(serverId));
+ for (size_t i = 0; i < countof(serverId); i++) {
sp<IBinder> server;
BinderLibTestBundle datai;
BinderLibTestBundle datai2;
@@ -662,7 +660,7 @@
EXPECT_EQ(0, id);
ASSERT_THAT(reply.readInt32(&count), StatusEq(NO_ERROR));
- EXPECT_EQ(ARRAY_SIZE(serverId), (size_t)count);
+ EXPECT_EQ(countof(serverId), (size_t)count);
for (size_t i = 0; i < (size_t)count; i++) {
int32_t counti;
@@ -2112,10 +2110,9 @@
if (index == 0) {
ret = sm->addService(binderLibTestServiceName, testService);
} else {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ LIBBINDER_IGNORE("-Wdeprecated-declarations")
sp<IBinder> server = sm->getService(binderLibTestServiceName);
-#pragma clang diagnostic pop
+ LIBBINDER_IGNORE_END()
Parcel data, reply;
data.writeInt32(index);
data.writeStrongBinder(testService);