[Libguestfs] [libnbd PATCH 0/6] finish wrapping generated C code harder

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


This is the last wave (wave 5). Line length maxima:

  file              before  after
  ----------------  ------  -----
  lib/states-run.c     102     98
  lib/states.c         116     80
  lib/states.h         123     86

The longest line in "lib/states.h" becomes:

> extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (
>              struct nbd_handle *h, bool *blocked
>            );

The one in "lib/states-run.c":

>     case STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD:
>       r = nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (h, &blocked);
>       break;

We couldn't find a "scalable" approach for shortening these (the state
machine can be nested indefinitely deeply), so we decided to live with
them.

Thanks
Laszlo
Laszlo Ersek (6):
  state_machine_generator: wrap debug() calls in nbd_internal_run()
  generator/utils: add "pr_wrap_c_comment"
  state_machine_generator: wrap state comments in lib/states.{h,c}
  state_machine_generator: wrap nbd_internal_enter_* prototypes
  state_machine_generator: wrap enter_*() calls and prototypes
  state_machine_generator: rename, and break up the init. of,
    "next_state"

 generator/state_machine_generator.ml | 48 +++++++----
 generator/utils.ml                   | 87 ++++++++++++++++++++
 generator/utils.mli                  |  1 +
 3 files changed, 119 insertions(+), 17 deletions(-)


base-commit: 99d18799f4079b9be073a3d1b0b9bf5beccf0dff


More information about the Libguestfs mailing list