[omniORB] [PATCH] omniidl: Avoid omniCallDescriptor* cd unused parameter warnings

David Ward david.ward at ll.mit.edu
Mon Jul 25 01:24:05 BST 2016


Commit r5660 removed most unused parameter warnings in local call
call-back functions generated by omniidl. However, these warnings
may still appear when there are user exceptions, but there are no
contexts, arguments, or return value. In this case, the parameter
cd is unused if HAS_Cplusplus_catch_exception_by_base is defined,
and a compiler warning may appear as a result. This change avoids
these warnings, by removing the parameter name from the function
definition when this is defined.

This is written in a way to have a minimal impact on the existing
code, while preserving the coding style. However, there are other
ways this fix could be implemented: for example, defining a macro
to be used in the function definition which expands to " cd" when
HAS_Cplusplus_catch_exception_by_base is defined.

Signed-off-by: David Ward <david.ward at ll.mit.edu>

Index: omniORB/src/lib/omniORB/python/omniidl_be/cxx/skel/template.py
===================================================================
--- omniORB/src/lib/omniORB/python/omniidl_be/cxx/skel/template.py	(revision 6328)
+++ omniORB/src/lib/omniORB/python/omniidl_be/cxx/skel/template.py	(working copy)
@@ -371,7 +371,8 @@
 {
   @get_call_descriptor@
   @impl_fqname@* impl = (@impl_fqname@*) svnt->_ptrToInterface(@name@::_PD_repoId);
- at impl_call@
+ at impl_ctxt@
+  @result at impl->@cxx_operation_name@(@operation_arguments@);
 }
 """
 
@@ -383,14 +384,24 @@
     ctxt = ::CORBA::Context::filterContext(tcd->ctxt, @cname@, @count@);
 """
 
-interface_callback_invoke = """\
-  @result at impl->@cxx_operation_name@(@operation_arguments@);
-"""
-
 interface_callback_tryblock = """\
+// Local call call-back function.
 #ifdef HAS_Cplusplus_catch_exception_by_base
+static void
+ at local_call_descriptor@(omniCallDescriptor*@cd_arg@, omniServant* svnt)
+{
+  @get_call_descriptor@
+  @impl_fqname@* impl = (@impl_fqname@*) svnt->_ptrToInterface(@name@::_PD_repoId);
+ at impl_ctxt@
   @result at impl->@cxx_operation_name@(@operation_arguments@);
+}
 #else
+static void
+ at local_call_descriptor@(omniCallDescriptor* cd, omniServant* svnt)
+{
+  @get_call_descriptor@
+  @impl_fqname@* impl = (@impl_fqname@*) svnt->_ptrToInterface(@name@::_PD_repoId);
+ at impl_ctxt@
   if (!cd->is_upcall())
     @result at impl->@cxx_operation_name@(@operation_arguments@);
   else {
@@ -399,6 +410,7 @@
     }
     @catch@
   }
+}
 #endif
 """
 
Index: omniORB/src/lib/omniORB/python/omniidl_be/cxx/call.py
===================================================================
--- omniORB/src/lib/omniORB/python/omniidl_be/cxx/call.py	(revision 6328)
+++ omniORB/src/lib/omniORB/python/omniidl_be/cxx/call.py	(working copy)
@@ -281,11 +281,10 @@
         if self.__contexts:
             impl_args.append("ctxt")
 
-        # If we have no return value, no arguments, no exceptions, and
-        # no contexts, we don't use the call descriptor argument at
-        # all, so we do not give it a name, so as to avoid warnings on
-        # some compilers.
-        if result_string or impl_args or self.__exceptions or self.__contexts:
+        # If we have no return value, no arguments, and no contexts, we don't
+        # use the call descriptor argument at all, so we do not give it a name,
+        # so as to avoid warnings on some compilers.
+        if result_string or impl_args or self.__contexts:
             cd_arg = " cd"
         else:
             cd_arg = ""
@@ -298,12 +297,12 @@
         else:
             get_cd = ""
 
-        impl_call = output.StringStream()
+        impl_ctxt = output.StringStream()
         catch = output.StringStream()
 
         # Deal with context
         if self.__contexts:
-            impl_call.out(template.interface_callback_context,
+            impl_ctxt.out(template.interface_callback_context,
                           cname = self.__context_name,
                           count = str(len(self.__contexts)))
 
@@ -315,24 +314,22 @@
                 catch.out(template.interface_operation_catch_exn,
                           exname = ex_scopedName.fullyQualify())
 
-            impl_call.out(template.interface_callback_tryblock,
-                          result = result_string,
-                          cxx_operation_name = operation,
-                          operation_arguments = ", ".join(impl_args),
-                          catch = str(catch))
+            tmpl = template.interface_callback_tryblock
+
         else:
-            impl_call.out(template.interface_callback_invoke,
-                          result = result_string,
-                          cxx_operation_name = operation,
-                          operation_arguments = ", ".join(impl_args))
+            tmpl = template.interface_callback
 
-        stream.out(template.interface_callback,
+        stream.out(tmpl,
                    local_call_descriptor = function_name,
                    cd_arg = cd_arg,
                    get_call_descriptor = get_cd,
                    impl_fqname =interface_name.prefix("_impl_").fullyQualify(),
                    name = interface_name.fullyQualify(),
-                   impl_call = str(impl_call))
+                   impl_ctxt = str(impl_ctxt),
+                   result = result_string,
+                   cxx_operation_name = operation,
+                   operation_arguments = ", ".join(impl_args),
+                   catch = str(catch))
 
 
     def out_objrefcall(self,stream,operation,args,localcall_fn,environment):



More information about the omniORB-list mailing list