Use a local boolean flag for unnesting the *_in_permitted_state() function call. The one place where this change currently matters is [lib/api.c]:
@@ -4787,29 +4925,31 @@ aio_connect_systemd_socket_activation_in return true; }
int nbd_aio_connect_systemd_socket_activation (struct nbd_handle *h, char **argv) { + bool p; int ret;
nbd_internal_set_error_context ("nbd_aio_connect_systemd_socket_activation");
pthread_mutex_lock (&h->lock); if_debug (h) { char *argv_printable = nbd_internal_printable_string_list (argv); debug (h, "enter: argv=%s", argv_printable ? argv_printable : ""); free (argv_printable); }
- if (unlikely (!aio_connect_systemd_socket_activation_in_permitted_state (h))) { + p = aio_connect_systemd_socket_activation_in_permitted_state (h); + if (unlikely (!p)) { ret = -1; goto out; } if (argv == NULL) { set_error (EFAULT, "%s cannot be NULL", "argv"); ret = -1; goto out;
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- Notes: v2: - declare "p" near the top of the function [Eric] generator/C.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generator/C.ml b/generator/C.ml index cf44424517de..e68fd70382cf 100644 --- a/generator/C.ml +++ b/generator/C.ml @@ -569,6 +569,8 @@ let print_arg_list ~wrap:true ~handle:true args optargs; pr "\n"; pr "{\n"; + if permitted_states <> [] then + pr " bool p;\n"; pr " %s ret;\n" ret_c_type; pr "\n"; if may_set_error then ( @@ -599,7 +601,8 @@ let let value = match errcode with | Some value -> value | None -> assert false in - pr " if (unlikely (!%s_in_permitted_state (h))) {\n" name; + pr " p = %s_in_permitted_state (h);\n" name; + pr " if (unlikely (!p)) {\n"; pr " ret = %s;\n" value; pr " goto out;\n"; pr " }\n";