From: Hwankyu Jhun Date: Tue, 16 May 2023 00:00:28 +0000 (+0000) Subject: Fix sign compare warning X-Git-Tag: accepted/tizen/unified/20230705.063732~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F47%2F292847%2F1;p=platform%2Fcore%2Fappfw%2Ftidl.git Fix sign compare warning The type of return value of sizeof is size_t. Some build system enables '-Wsign-compare' build option. It makes a build warning. This patch adds a new variable to store the return value of sizeof. And, it will be used to compare variables. Change-Id: Iad724ec2ca88cc7b8d5c6cf6b3a15ed6b6c1dd3b Signed-off-by: Hwankyu Jhun --- diff --git a/idlc/gen/c_group_body_gen_cb.h b/idlc/gen/c_group_body_gen_cb.h index f27f2b4..6721555 100644 --- a/idlc/gen/c_group_body_gen_cb.h +++ b/idlc/gen/c_group_body_gen_cb.h @@ -205,7 +205,9 @@ static void ___event_system_cb(const char *event_name, bundle *event_data, _W("[Sequence] %d", seq_num); rpc_port_parcel_read_int32(p, &cmd); - if (cmd > 1 && cmd < ARRAY_SIZE(___method_table)) { + + static const int table_size = ARRAY_SIZE(___method_table); + if (cmd > 1 && cmd < table_size) { if (___method_table[cmd]) ___method_table[cmd](p, handle); } else { diff --git a/idlc/gen/c_proxy_body_gen_cb.h b/idlc/gen/c_proxy_body_gen_cb.h index 780e4b5..d646f16 100644 --- a/idlc/gen/c_proxy_body_gen_cb.h +++ b/idlc/gen/c_proxy_body_gen_cb.h @@ -474,13 +474,14 @@ static void ____process_received_event(GList **delegates, rpc_port int id = 0; int seq_id = 0; bool once = false; + static const int table_size = ARRAY_SIZE(____delegate_table); rpc_port_parcel_read_int32(parcel, &id); rpc_port_parcel_read_int32(parcel, &seq_id); rpc_port_parcel_read_bool(parcel, &once); _W("id(%d), seq_id(%d)", id, seq_id); - if (id > 0 && id < ARRAY_SIZE(____delegate_table)) { + if (id > 0 && id < table_size) { if (____delegate_table[id]) ____delegate_table[id](delegates, parcel, id, seq_id); } else { diff --git a/idlc/gen/c_stub_body_gen_cb.h b/idlc/gen/c_stub_body_gen_cb.h index aafe2f1..c1214fc 100644 --- a/idlc/gen/c_stub_body_gen_cb.h +++ b/idlc/gen/c_stub_body_gen_cb.h @@ -149,9 +149,10 @@ static int ____context_handle_request(__context_h h, { int ret = RPC_PORT_ERROR_NONE; int cmd = -1; + static const int table_size = ARRAY_SIZE(___method_table); rpc_port_parcel_read_int32(parcel, &cmd); - if (cmd > 1 && cmd < ARRAY_SIZE(___method_table)) { + if (cmd > 1 && cmd < table_size) { if (___method_table[cmd]) ret = ___method_table[cmd](h->port, parcel, h); } else { diff --git a/idlc/gen_cion/c_cion_group_body_gen_cb.h b/idlc/gen_cion/c_cion_group_body_gen_cb.h index b48ccc1..f3aeb90 100644 --- a/idlc/gen_cion/c_cion_group_body_gen_cb.h +++ b/idlc/gen_cion/c_cion_group_body_gen_cb.h @@ -137,9 +137,10 @@ static int ____process_received_event(__t *h, const { int ret = _ERROR_NONE; int cmd = -1; + static const int table_size = ARRAY_SIZE(___method_table); rpc_port_parcel_read_int32(parcel, &cmd); - if (cmd >= 0 && cmd < ARRAY_SIZE(___method_table)) { + if (cmd >= 0 && cmd < table_size) { if (___method_table[cmd]) ret = ___method_table[cmd](peer_info, parcel, h); } else { diff --git a/idlc/gen_cion/c_cion_proxy_body_gen_cb.h b/idlc/gen_cion/c_cion_proxy_body_gen_cb.h index 68513c7..c3dd444 100644 --- a/idlc/gen_cion/c_cion_proxy_body_gen_cb.h +++ b/idlc/gen_cion/c_cion_proxy_body_gen_cb.h @@ -473,13 +473,14 @@ static void ____process_received_event(GList **delegates, rpc_port int id = 0; int seq_id = 0; bool once = false; + static const int table_size = ARRAY_SIZE(____delegate_table); rpc_port_parcel_read_int32(parcel, &id); rpc_port_parcel_read_int32(parcel, &seq_id); rpc_port_parcel_read_bool(parcel, &once); _W("id(%d), seq_id(%d)", id, seq_id); - if (id > 0 && id < ARRAY_SIZE(____delegate_table)) { + if (id > 0 && id < table_size) { if (____delegate_table[id]) ____delegate_table[id](delegates, parcel, id, seq_id); } else { diff --git a/idlc/gen_cion/c_cion_stub_body_gen_cb.h b/idlc/gen_cion/c_cion_stub_body_gen_cb.h index 06082d7..b16e7cf 100644 --- a/idlc/gen_cion/c_cion_stub_body_gen_cb.h +++ b/idlc/gen_cion/c_cion_stub_body_gen_cb.h @@ -119,9 +119,10 @@ static int ____process_received_event(__t *h, const { int ret = _ERROR_NONE; int cmd = -1; + static const int table_size = ARRAY_SIZE(___method_table); rpc_port_parcel_read_int32(parcel, &cmd); - if (cmd > 1 && cmd < ARRAY_SIZE(___method_table)) { + if (cmd > 1 && cmd < table_size) { if (___method_table[cmd]) ret = ___method_table[cmd](peer_info, parcel, return_parcel, h); } else {