Laszlo Ersek
2023-May-10 11:48 UTC
[Libguestfs] [libnbd PATCH 3/6] state_machine_generator: wrap state comments in lib/states.{h, c}
Wrap those comments in "lib/states.h" and "lib/states.c" that describe the automaton's states. Example changes from "lib/states.h":> /* CONNECT_TCP.CONNECT: Initial call to connect(2) on a TCP socket */ > STATE_CONNECT_TCP_CONNECT, > > - /* CONNECT_TCP.CONNECTING: Connecting to the remote server over a TCP socket */ > + /* CONNECT_TCP.CONNECTING: Connecting to the remote server over a TCP socket > + */ > STATE_CONNECT_TCP_CONNECTING, >and> STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_QUERY, > > - /* NEWSTYLE.OPT_META_CONTEXT.PREPARE_FOR_REPLY: Prepare to receive newstyle NBD_OPT_SET_META_CONTEXT option reply */ > + /* NEWSTYLE.OPT_META_CONTEXT.PREPARE_FOR_REPLY: Prepare to receive newstyle > + * NBD_OPT_SET_META_CONTEXT option reply > + */ > STATE_NEWSTYLE_OPT_META_CONTEXT_PREPARE_FOR_REPLY, >Example changes from "lib/states.c":> @@ -2085,7 +2087,8 @@ nbd_internal_enter_STATE_NEWSTYLE_OPT_ST > return r; > } > > -/* NEWSTYLE.OPT_STARTTLS.SEND: Send newstyle NBD_OPT_STARTTLS to upgrade to TLS */ > +/* NEWSTYLE.OPT_STARTTLS.SEND: Send newstyle NBD_OPT_STARTTLS to upgrade to TLS > + */ > static int > enter_STATE_NEWSTYLE_OPT_STARTTLS_SEND (struct nbd_handle *h, > enum state *next_state,and> @@ -2992,7 +3021,9 @@ nbd_internal_enter_STATE_NEWSTYLE_OPT_ME > return r; > } > > -/* NEWSTYLE.OPT_META_CONTEXT.PREPARE_FOR_REPLY: Prepare to receive newstyle NBD_OPT_SET_META_CONTEXT option reply */ > +/* NEWSTYLE.OPT_META_CONTEXT.PREPARE_FOR_REPLY: Prepare to receive newstyle > + * NBD_OPT_SET_META_CONTEXT option reply > + */ > static int > enter_STATE_NEWSTYLE_OPT_META_CONTEXT_PREPARE_FOR_REPLY (struct nbd_handle *h, > enum state *next_state,Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- generator/state_machine_generator.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generator/state_machine_generator.ml b/generator/state_machine_generator.ml index 3df706f91ccd..74a009a33598 100644 --- a/generator/state_machine_generator.ml +++ b/generator/state_machine_generator.ml @@ -298,7 +298,9 @@ let pr "enum state {\n"; List.iter ( fun ({ comment; parsed = { display_name; state_enum } }) -> - pr " /* %s: %s */\n" display_name comment; + pr " "; + pr_wrap_c_comment (fun () -> pr "%s: %s" display_name comment); + pr "\n"; pr " %s,\n" state_enum; pr "\n"; ) states; @@ -346,7 +348,8 @@ let List.iter ( fun { comment; parsed = { display_name; state_enum; loc; code } } -> pr "\n"; - pr "/* %s: %s */\n" display_name comment; + 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";
Eric Blake
2023-May-10 15:14 UTC
[Libguestfs] [libnbd PATCH 3/6] state_machine_generator: wrap state comments in lib/states.{h, c}
On Wed, May 10, 2023 at 01:48:11PM +0200, Laszlo Ersek wrote:> Wrap those comments in "lib/states.h" and "lib/states.c" that describe the > automaton's states. > > Example changes from "lib/states.h": > > > /* CONNECT_TCP.CONNECT: Initial call to connect(2) on a TCP socket */ > > STATE_CONNECT_TCP_CONNECT, > > > > - /* CONNECT_TCP.CONNECTING: Connecting to the remote server over a TCP socket */ > > + /* CONNECT_TCP.CONNECTING: Connecting to the remote server over a TCP socket > > + */This one looks a bit unusual; I didn't find any instances of this style in existing hand-written comments ( git grep -B1 '^[:space:]*\*/$' | grep '/\*' ). But I saw the code you had in the previous patch that produced it, and don't see any way to force the wrap one word earlier in this particular instance without adding even more complexity. So I'm okay with how it ended up. Reviewed-by: Eric Blake <eblake at redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org