[Libguestfs] [PATCH 1/1] ocaml: make const the return value of caml_named_value()
Richard W.M. Jones
rjones at redhat.com
Thu Sep 5 09:01:45 UTC 2019
On Thu, Sep 05, 2019 at 10:47:42AM +0200, Pino Toscano wrote:
> With OCaml >= 4.09 caml_named_value() returns a const value *, so keep
> the constness to build also in this case.
> ---
> common/mlpcre/pcre-c.c | 2 +-
> common/mltools/uri-c.c | 2 +-
> common/mlvisit/visit-c.c | 2 +-
> generator/daemon.ml | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
> index be054a004..62a6dd5da 100644
> --- a/common/mlpcre/pcre-c.c
> +++ b/common/mlpcre/pcre-c.c
> @@ -73,7 +73,7 @@ init (void)
> static void
> raise_pcre_error (const char *msg, int errcode)
> {
> - value *exn = caml_named_value ("PCRE.Error");
> + const value *exn = caml_named_value ("PCRE.Error");
> value args[2];
>
> args[0] = caml_copy_string (msg);
> diff --git a/common/mltools/uri-c.c b/common/mltools/uri-c.c
> index 2a8837cd9..db6fe23fc 100644
> --- a/common/mltools/uri-c.c
> +++ b/common/mltools/uri-c.c
> @@ -47,7 +47,7 @@ guestfs_int_mllib_parse_uri (value argv /* arg value, not an array! */)
>
> r = parse_uri (String_val (argv), &uri);
> if (r == -1) {
> - value *exn = caml_named_value ("URI.Parse_failed");
> + const value *exn = caml_named_value ("URI.Parse_failed");
In my version I got rid of the useless local variable.
Rich.
> caml_raise (*exn);
> }
>
> diff --git a/common/mlvisit/visit-c.c b/common/mlvisit/visit-c.c
> index 7137c4998..804aabc9d 100644
> --- a/common/mlvisit/visit-c.c
> +++ b/common/mlvisit/visit-c.c
> @@ -53,7 +53,7 @@ value
> guestfs_int_mllib_visit (value gv, value dirv, value fv)
> {
> CAMLparam3 (gv, dirv, fv);
> - value *visit_failure_exn;
> + const value *visit_failure_exn;
> guestfs_h *g = (guestfs_h *) (intptr_t) Int64_val (gv);
> struct visitor_function_wrapper_args args;
> /* The dir string could move around when we call the
> diff --git a/generator/daemon.ml b/generator/daemon.ml
> index a4e136aaa..b67c4d20b 100644
> --- a/generator/daemon.ml
> +++ b/generator/daemon.ml
> @@ -746,7 +746,7 @@ let generate_daemon_caml_stubs () =
> let nr_args = List.length args_do_function in
>
> pr "{\n";
> - pr " static value *cb = NULL;\n";
> + pr " static const value *cb = NULL;\n";
> pr " CAMLparam0 ();\n";
> pr " CAMLlocal2 (v, retv);\n";
> pr " CAMLlocalN (args, %d);\n"
> --
> 2.21.0
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
More information about the Libguestfs
mailing list