[Libguestfs] [libnbd PATCH 5/6] state_machine_generator: wrap enter_*() calls and prototypes
Laszlo Ersek
lersek at redhat.com
Wed May 10 11:48:13 UTC 2023
More of the same.
Regarding the enter_*() calls, most impactful change is [lib/states.c]:
> @@ -2635,7 +2695,9 @@ nbd_internal_enter_STATE_NEWSTYLE_OPT_ST
> int r;
> enum state next_state = STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD;
>
> - r = enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (h, &next_state, blocked);
> + r = enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (
> + h, &next_state, blocked
> + );
> if (get_next_state (h) != next_state) {
> debug (h, "transition: %s -> %s",
> "NEWSTYLE.OPT_STRUCTURED_REPLY.RECV_REPLY_PAYLOAD",
(Note that using "pr_wrap" instead of the fixed manual wrapping would have
both advantages and disadvantages:
- Many state paths (formatted with underscores in "state_name") are
actually short; "pr_wrap" would keep those enter_*() calls unchanged.
- A few state paths are extremely long however, and such a path is
generally unbounded. For example, even the opening parenthesis could be
in column 80+. That would make "pr_wrap" entirely useless.)
While at it, update the existent manual wrapping for the enter_*()
prototypes as well; that makes the calls and the prototypes look uniform,
plus it actually removes at least one overlong line [lib/states.c]:
> @@ -2612,9 +2672,9 @@ nbd_internal_enter_STATE_NEWSTYLE_OPT_ST
> * NBD_OPT_STRUCTURED_REPLY reply payload
> */
> static int
> -enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (struct nbd_handle *h,
> - enum state *next_state,
> - bool *blocked)
> +enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (
> + struct nbd_handle *h, enum state *next_state, bool *blocked
> +)
> {
> #line 68 "generator/states-newstyle-opt-structured-reply.c"
>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
generator/state_machine_generator.ml | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/generator/state_machine_generator.ml b/generator/state_machine_generator.ml
index 8667adeacf7a..af07e4ff3966 100644
--- a/generator/state_machine_generator.ml
+++ b/generator/state_machine_generator.ml
@@ -353,9 +353,9 @@ let
pr_wrap_c_comment (fun () -> pr "%s: %s" display_name comment);
pr "\n";
pr "static int\n";
- pr "enter_%s (struct nbd_handle *h,\n" state_enum;
- pr " enum state *next_state,\n";
- pr " bool *blocked)\n";
+ pr "enter_%s (\n" state_enum;
+ pr " struct nbd_handle *h, enum state *next_state, bool *blocked\n";
+ pr ")\n";
pr "{\n";
if code <> "" then (
pr "%s\n" (line_directive_of_location loc);
@@ -375,7 +375,9 @@ let
pr " int r;\n";
pr " enum state next_state = %s;\n" state_enum;
pr "\n";
- pr " r = enter_%s (h, &next_state, blocked);\n" state_enum;
+ pr " r = enter_%s (\n" state_enum;
+ pr " h, &next_state, blocked\n";
+ pr " );\n";
pr " if (get_next_state (h) != next_state) {\n";
pr " debug (h, \"transition: %%s -> %%s\",\n";
pr " \"%s\",\n" display_name;
More information about the Libguestfs
mailing list