ocaml: Change calls to caml_named_value() to cope with const value* return.

In OCaml >= 4.09 the return value pointer of caml_named_value is
declared const.

Based on Pino Toscano's original patch to ocaml-augeas.
This commit is contained in:
Richard W.M. Jones
2019-09-05 09:00:14 +01:00
parent fcfdbc9420
commit 74ce7332db
4 changed files with 5 additions and 10 deletions

View File

@@ -73,12 +73,11 @@ init (void)
static void
raise_pcre_error (const char *msg, int errcode)
{
value *exn = caml_named_value ("PCRE.Error");
value args[2];
args[0] = caml_copy_string (msg);
args[1] = Val_int (errcode);
caml_raise_with_args (*exn, 2, args);
caml_raise_with_args (*caml_named_value ("PCRE.Error"), 2, args);
}
/* Wrap and unwrap pcre regular expression handles, with a finalizer. */

View File

@@ -46,10 +46,8 @@ guestfs_int_mllib_parse_uri (value argv /* arg value, not an array! */)
int r;
r = parse_uri (String_val (argv), &uri);
if (r == -1) {
value *exn = caml_named_value ("URI.Parse_failed");
caml_raise (*exn);
}
if (r == -1)
caml_raise (*caml_named_value ("URI.Parse_failed"));
/* Convert the struct into an OCaml tuple. */
rv = caml_alloc_tuple (5);

View File

@@ -53,7 +53,6 @@ value
guestfs_int_mllib_visit (value gv, value dirv, value fv)
{
CAMLparam3 (gv, dirv, fv);
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
@@ -84,8 +83,7 @@ guestfs_int_mllib_visit (value gv, value dirv, value fv)
* already printed the error to stderr (XXX - fix), so we raise a
* generic exception.
*/
visit_failure_exn = caml_named_value ("Visit.Failure");
caml_raise (*visit_failure_exn);
caml_raise (*caml_named_value ("Visit.Failure"));
}
free (dir);

View File

@@ -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"