[Libguestfs] [libnbd PATCH 1/6] state_machine_generator: wrap debug() calls in nbd_internal_run()

Laszlo Ersek lersek at redhat.com
Wed May 10 11:48:09 UTC 2023


The longest line in "lib/states-run.c" is folded as follows:

> @@ -513,8 +515,9 @@ nbd_internal_run (struct nbd_handle *h,
>        goto ok;
>      case notify_read:
>        set_next_state (h, STATE_ISSUE_COMMAND_PAUSE_WRITE_SHUTDOWN);
> -      debug (h, "event %s: %s -> %s",
> -             "NotifyRead", "ISSUE_COMMAND.SEND_WRITE_SHUTDOWN", "ISSUE_COMMAND.PAUSE_WRITE_SHUTDOWN");
> +      debug (h, "event %s: %s -> %s", "NotifyRead",
> +             "ISSUE_COMMAND.SEND_WRITE_SHUTDOWN",
> +             "ISSUE_COMMAND.PAUSE_WRITE_SHUTDOWN");
>        goto ok;
>      default: ; /* nothing, silence GCC warning */
>      }

Note: this is the last (aka "only") wrapping-related patch for
"lib/states-run.c". We still have overlong lines, but those come from
generated single-identifier names such as
nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD().
After discussing those with Rich and Eric, we're going to leave them
alone.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 generator/state_machine_generator.ml | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/generator/state_machine_generator.ml b/generator/state_machine_generator.ml
index 43c1ce4c14dc..3df706f91ccd 100644
--- a/generator/state_machine_generator.ml
+++ b/generator/state_machine_generator.ml
@@ -414,10 +414,15 @@ let
             pr "    case %s:\n" (c_string_of_external_event e);
             if state != next_state then (
               pr "      set_next_state (h, %s);\n" next_state.parsed.state_enum;
-              pr "      debug (h, \"event %%s: %%s -> %%s\",\n";
-              pr "             \"%s\", \"%s\", \"%s\");\n"
-                 (string_of_external_event e)
-                 display_name next_state.parsed.display_name;
+              pr "      debug (";
+              let print_debug_args () =
+                pr "h, \"event %%s: %%s -> %%s\", ";
+                pr "\"%s\", \"%s\", \"%s\");"
+                   (string_of_external_event e)
+                   display_name next_state.parsed.display_name;
+              in
+              pr_wrap ',' print_debug_args;
+              pr "\n"
             );
             pr "      goto ok;\n";
         ) events;



More information about the Libguestfs mailing list