Just omit the various 'return' when the return type is void. Signed-off-by: Emanuele Giuseppe Esposito <eespo...@redhat.com> --- scripts/block-coroutine-wrapper.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index 05267761f0..8d7aa5d7f4 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -115,7 +115,7 @@ def create_g_c_w(func: FuncDecl) -> str: {func.return_type} {func.name}({ func.gen_list('{decl}') }) {{ if (qemu_in_coroutine()) {{ - return {name}({ func.gen_list('{name}') }); + {func.co_ret}{name}({ func.gen_list('{name}') }); }} else {{ {struct_name} s = {{ .poll_state.bs = {func.bs}, @@ -127,7 +127,7 @@ def create_g_c_w(func: FuncDecl) -> str: s.poll_state.co = qemu_coroutine_create({name}_entry, &s); bdrv_poll_co(&s.poll_state); - return s.ret; + {func.ret} }} }}""" @@ -150,7 +150,7 @@ def create_coroutine_only(func: FuncDecl) -> str: s.poll_state.co = qemu_coroutine_create({name}_entry, &s); bdrv_poll_co(&s.poll_state); - return s.ret; + {func.ret} }}""" @@ -168,6 +168,15 @@ def gen_wrapper(func: FuncDecl) -> str: graph_lock=' bdrv_graph_co_rdlock();' graph_unlock=' bdrv_graph_co_rdunlock();' + func.get_result = 's->ret = ' + func.ret = 'return s.ret;' + func.co_ret = 'return ' + func.return_field = func.return_type + " ret;" + if func.return_type == 'void': + func.get_result = '' + func.ret = '' + func.co_ret = '' + func.return_field = '' t = func.args[0].type if t == 'BlockDriverState *': @@ -193,7 +202,7 @@ def gen_wrapper(func: FuncDecl) -> str: typedef struct {struct_name} {{ BdrvPollCo poll_state; - {func.return_type} ret; + {func.return_field} { func.gen_block(' {decl};') } }} {struct_name}; @@ -202,7 +211,7 @@ def gen_wrapper(func: FuncDecl) -> str: {struct_name} *s = opaque; {graph_lock} - s->ret = {name}({ func.gen_list('s->{name}') }); + {func.get_result}{name}({ func.gen_list('s->{name}') }); {graph_unlock} s->poll_state.in_progress = false; -- 2.31.1