[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH libnbd] generator: Swap parameters of nbd_add_close_callback.



The API changes from:

  int nbd_add_close_callback (struct nbd_handle *h,
                              nbd_close_callback cb,
                              void *user_data);

to:

  int nbd_add_close_callback (struct nbd_handle *h,
                              void *user_data,
                              nbd_close_callback cb);

The second way is consistent with how other callbacks work throughout
the API (ie. having the user_data passed first).
---
 generator/generator | 10 +++++-----
 lib/handle.c        |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/generator/generator b/generator/generator
index 951349d..ed05ea9 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3305,8 +3305,8 @@ let generate_include_libnbd_h () =
   pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n";
   pr "\n";
   pr "extern int nbd_add_close_callback (struct nbd_handle *h,\n";
-  pr "                                   nbd_close_callback cb,\n";
-  pr "                                   void *user_data);\n";
+  pr "                                   void *user_data,\n";
+  pr "                                   nbd_close_callback cb);\n";
   pr "#define LIBNBD_HAVE_NBD_ADD_CLOSE_CALLBACK 1\n";
   pr "\n";
   List.iter (
@@ -3593,7 +3593,7 @@ from other programming languages.
 
  typedef void (*nbd_close_callback) (void *user_data);
  int nbd_add_close_callback (struct nbd_handle *nbd,
-                             nbd_close_callback cb, void *user_data);
+                             void *user_data, nbd_close_callback cb);
 
 ";
 
@@ -4195,7 +4195,7 @@ let print_python_binding name { args; ret } =
     | Closure (false, _) -> ()
     | Closure (true, _) ->
        pr "  /* This ensures the callback data is freed eventually. */\n";
-       pr "  nbd_add_close_callback (h, free_%s_user_data, user_data);\n" name
+       pr "  nbd_add_close_callback (h, user_data, free_%s_user_data);\n" name
     | Flags _ -> ()
     | Int _ -> ()
     | Int64 _ -> ()
@@ -4862,7 +4862,7 @@ let print_ocaml_binding (name, { args; ret }) =
   (match has_closures with
    | None | Some false -> ()
    | Some true ->
-      pr "  nbd_add_close_callback (h, free_%s_user_data, user_data);\n" name
+      pr "  nbd_add_close_callback (h, user_data, free_%s_user_data);\n" name
   );
 
   let errcode =
diff --git a/lib/handle.c b/lib/handle.c
index 5003227..00d0ac2 100644
--- a/lib/handle.c
+++ b/lib/handle.c
@@ -203,7 +203,7 @@ nbd_unlocked_add_meta_context (struct nbd_handle *h, const char *name)
  */
 int
 nbd_add_close_callback (struct nbd_handle *h,
-                        nbd_close_callback cb, void *user_data)
+                        void *user_data, nbd_close_callback cb)
 {
   int ret;
   struct close_callback *cc;
-- 
2.22.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]