From be128ed9d18db8e8a86afd913e20e2fadcee342a Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 3 Aug 2018 11:00:30 +0900 Subject: [PATCH] Add initializer for callback handle Change-Id: I869f77ffc89a255ecb93199c4f370610ed4a7753 Signed-off-by: Junghoon Park --- idlc/c_gen/c_stub_body_gen.cc | 6 +++++- idlc/c_gen/c_stub_body_gen_cb.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/idlc/c_gen/c_stub_body_gen.cc b/idlc/c_gen/c_stub_body_gen.cc index d340aef..565d7ea 100644 --- a/idlc/c_gen/c_stub_body_gen.cc +++ b/idlc/c_gen/c_stub_body_gen.cc @@ -181,7 +181,7 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf, if (IsDelegateType(inf, i->GetParameterType().GetBaseType())) { str += "rpc_port_" + GetInterfaceIdWithNamespace(inf) + "_" + i->GetParameterType().GetBaseType().ToString() + "_h " + - i->GetID() + ";" + NLine(1); + i->GetID() + " = NULL;" + NLine(1); } else { str += GetReturnTypeString(i->GetParameterType().GetBaseType()) + i->GetID() + ";" + NLine(1); @@ -202,6 +202,10 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf, str += "rpc_port_" + GetInterfaceIdWithNamespace(inf) + "_" + i->GetParameterType().GetBaseType().ToString() + "_create(&" + i->GetID() + ");" + NLine(1); + str += "\nif (!" + i->GetID() + ") {\n"; + str += " _E(\"Failed to create handle\");\n"; + str += " return -1;\n"; + str += "}\n\n"; str += GenTemplateString(port_setter, [&]()->std::string { return GetInterfaceIdWithNamespace(inf) + "_" + diff --git a/idlc/c_gen/c_stub_body_gen_cb.h b/idlc/c_gen/c_stub_body_gen_cb.h index a9bce78..db744e2 100644 --- a/idlc/c_gen/c_stub_body_gen_cb.h +++ b/idlc/c_gen/c_stub_body_gen_cb.h @@ -26,8 +26,10 @@ static int __$$_method_$$(rpc_port_h port, rpc_port_parcel_h parcel, void *data) int r; r = rpc_port_stub_get_port(__$$_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); - if (r != 0) + if (r != 0) { _E("Failed to get callback port"); + return -1; + } $$ return 0; -- 2.7.4