[Libguestfs] [libnbd PATCH 03/23] generator: wrap "python/libnbdmod.c" at 80 characters

Laszlo Ersek lersek at redhat.com
Tue Apr 25 07:10:47 UTC 2023


Break the fields of each PyMethodDef structure initializer to separate
lines.

While at it, drop the superfluous (char*) cast from the
"PyMethodDef.ml_name" field initializer
<https://docs.python.org/3/c-api/structures.html#c.PyMethodDef>.
(According to commit bf0eee111fc3, "Add Python 3 bindings.", 2019-05-11,
we don't target Python 2.)

Effect shown on the currently longest line in "python/libnbdmod.c":

> -  { (char *) "aio_connect_systemd_socket_activation", nbd_internal_py_aio_connect_systemd_socket_activation, METH_VARARGS, NULL },
> +  {
> +    "aio_connect_systemd_socket_activation",
> +    nbd_internal_py_aio_connect_systemd_socket_activation,
> +    METH_VARARGS,
> +    NULL
> +  },

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

diff --git a/generator/Python.ml b/generator/Python.ml
index 87444c54bdf0..c146f04f0b49 100644
--- a/generator/Python.ml
+++ b/generator/Python.ml
@@ -100,8 +100,12 @@ let
   pr "static PyMethodDef methods[] = {\n";
   List.iter (
     fun name ->
-      pr "  { (char *) \"%s\", nbd_internal_py_%s, METH_VARARGS, NULL },\n"
-         name name;
+      pr "  {\n";
+      pr "    \"%s\",\n" name;
+      pr "    nbd_internal_py_%s,\n" name;
+      pr "    METH_VARARGS,\n";
+      pr "    NULL\n";
+      pr "  },\n"
   ) ([ "create"; "close";
        "display_version";
        "alloc_aio_buffer";



More information about the Libguestfs mailing list