Add initializer for callback handle 35/185835/2
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 3 Aug 2018 02:00:30 +0000 (11:00 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 3 Aug 2018 02:02:05 +0000 (02:02 +0000)
Change-Id: I869f77ffc89a255ecb93199c4f370610ed4a7753
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
idlc/c_gen/c_stub_body_gen.cc
idlc/c_gen/c_stub_body_gen_cb.h

index d340aef..565d7ea 100644 (file)
@@ -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) + "_" +
index a9bce78..db744e2 100644 (file)
@@ -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;