Richard W.M. Jones
2017-Mar-03 10:17 UTC
[Libguestfs] [PATCH] erlang: Rename 'message' to something less generic.
It's not possible to define an action which takes a parameter called 'message' because the Erlang bindings use that as the name of an internal variable. Solve this by renaming the Erlang internal variable. Fixes commit 84763d7fca3668c62ee3fe53d0e00a5a672f687b. --- generator/erlang.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/generator/erlang.ml b/generator/erlang.ml index 3753835..d0d2198 100644 --- a/generator/erlang.ml +++ b/generator/erlang.ml @@ -192,7 +192,7 @@ and generate_erlang_actions_h () extern guestfs_h *g; -extern ETERM *dispatch (ETERM *message); +extern ETERM *dispatch (ETERM *args_tuple); extern int atom_equals (ETERM *atom, const char *name); extern ETERM *make_error (const char *funname); extern ETERM *unknown_optarg (const char *funname, ETERM *optargname); @@ -205,7 +205,7 @@ extern int get_bool (ETERM *term); extern int get_int (ETERM *term); extern int64_t get_int64 (ETERM *term); -#define ARG(i) (ERL_TUPLE_ELEMENT(message,(i)+1)) +#define ARG(i) (ERL_TUPLE_ELEMENT(args_tuple,(i)+1)) "; @@ -229,7 +229,7 @@ extern int64_t get_int64 (ETERM *term); List.iter ( fun { name = name } -> - pr "ETERM *run_%s (ETERM *message);\n" name + pr "ETERM *run_%s (ETERM *args_tuple);\n" name ) (actions |> external_functions |> sort); pr "\n"; @@ -355,7 +355,7 @@ instead of erl_interface. c_function = c_function; c_optarg_prefix = c_optarg_prefix } -> pr "\n"; pr "ETERM *\n"; - pr "run_%s (ETERM *message)\n" name; + pr "run_%s (ETERM *args_tuple)\n" name; pr "{\n"; iteri ( @@ -546,11 +546,11 @@ instead of erl_interface. #include \"actions.h\" ETERM * -dispatch (ETERM *message) +dispatch (ETERM *args_tuple) { ETERM *fun; - fun = ERL_TUPLE_ELEMENT (message, 0); + fun = ERL_TUPLE_ELEMENT (args_tuple, 0); /* XXX We should use gperf here. */ "; @@ -558,7 +558,7 @@ dispatch (ETERM *message) List.iter ( fun { name = name; style = ret, args, optargs } -> pr "if (atom_equals (fun, \"%s\"))\n" name; - pr " return run_%s (message);\n" name; + pr " return run_%s (args_tuple);\n" name; pr " else "; ) (actions |> external_functions |> sort); -- 2.9.3
Pino Toscano
2017-Mar-03 14:56 UTC
[Libguestfs] [PATCH] erlang: Rename 'message' to something less generic.
On Friday, 3 March 2017 11:17:53 CET Richard W.M. Jones wrote:> It's not possible to define an action which takes a parameter called > 'message' because the Erlang bindings use that as the name of an > internal variable. Solve this by renaming the Erlang internal > variable. > > Fixes commit 84763d7fca3668c62ee3fe53d0e00a5a672f687b. > ---LGTM -- if that variable is in a place that can conflict with action stuff, then I guess using 'erl_args_tuple' could reduce the likelihood of conflict even more. Thanks, -- Pino Toscano -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part. URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170303/f85bfe1b/attachment.sig>