[RFC PATCH v1 5/8] utils: codegen: ipc: Simplify `return` statements

Jacopo Mondi jacopo.mondi at ideasonboard.com
Tue May 20 13:49:21 CEST 2025


Hi Barnabás

On Thu, May 15, 2025 at 02:00:09PM +0200, Barnabás Pőcze wrote:
> Returning an expression of type `void` from a function returning `void`
> is legal, so do not handle those cases specially.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>


> ---
>  .../libcamera_templates/module_ipa_proxy.cpp.tmpl      | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
> index effc8f7dd..9a3aadbd2 100644
> --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
> +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
> @@ -127,13 +127,13 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
>  {{proxy_funcs.func_sig(proxy_name, method)}}
>  {
>  	if (isolate_)
> -		{{"return " if method|method_return_value != "void"}}{{method.mojom_name}}IPC(
> +		return {{method.mojom_name}}IPC(
>  {%- for param in method|method_param_names -%}
>  		{{param}}{{- ", " if not loop.last}}
>  {%- endfor -%}
>  );
>  	else
> -		{{"return " if method|method_return_value != "void"}}{{method.mojom_name}}Thread(
> +		return {{method.mojom_name}}Thread(
>  {%- for param in method|method_param_names -%}
>  		{{param}}{{- ", " if not loop.last}}
>  {%- endfor -%}
> @@ -159,16 +159,14 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
>  	state_ = ProxyRunning;
>  	thread_.start();
>
> -	{{ "return " if method|method_return_value != "void" -}}
> -	proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking
> +	return proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking
>  	{{- ", " if method|method_param_names}}
>  	{%- for param in method|method_param_names -%}
>  		{{param}}{{- ", " if not loop.last}}
>  	{%- endfor -%}
>  );
>  {%- elif not method|is_async %}
> -	{{ "return " if method|method_return_value != "void" -}}
> -	ipa_->{{method.mojom_name}}(
> +	return ipa_->{{method.mojom_name}}(
>  	{%- for param in method|method_param_names -%}
>  		{{param}}{{- ", " if not loop.last}}
>  	{%- endfor -%}
> --
> 2.49.0
>


More information about the libcamera-devel mailing list