mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0003-ocaml-Change-calls-to-caml_named_value-to-cope-with-.patch

5ce0c7
From 3860ab78d9fe5c34785aabc2227ebc8687b1171b Mon Sep 17 00:00:00 2001
5ce0c7
From: "Richard W.M. Jones" <rjones@redhat.com>
5ce0c7
Date: Thu, 5 Sep 2019 09:00:14 +0100
5ce0c7
Subject: [PATCH] ocaml: Change calls to caml_named_value() to cope with const
5ce0c7
 value* return.
5ce0c7
5ce0c7
In OCaml >= 4.09 the return value pointer of caml_named_value is
5ce0c7
declared const.
5ce0c7
5ce0c7
Based on Pino Toscano's original patch to ocaml-augeas.
5ce0c7
5ce0c7
(cherry picked from commit 9788fa50601ad4f1eab56d0b763591268026e536)
5ce0c7
---
5ce0c7
 common/mlpcre/pcre-c.c   | 3 +--
5ce0c7
 common/mltools/uri-c.c   | 6 ++----
5ce0c7
 common/mlvisit/visit-c.c | 4 +---
5ce0c7
 3 files changed, 4 insertions(+), 9 deletions(-)
5ce0c7
5ce0c7
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
5ce0c7
index 0762a8341..07f99b8d6 100644
5ce0c7
--- a/common/mlpcre/pcre-c.c
5ce0c7
+++ b/common/mlpcre/pcre-c.c
5ce0c7
@@ -73,12 +73,11 @@ init (void)
5ce0c7
 static void
5ce0c7
 raise_pcre_error (const char *msg, int errcode)
5ce0c7
 {
5ce0c7
-  value *exn = caml_named_value ("PCRE.Error");
5ce0c7
   value args[2];
5ce0c7
 
5ce0c7
   args[0] = caml_copy_string (msg);
5ce0c7
   args[1] = Val_int (errcode);
5ce0c7
-  caml_raise_with_args (*exn, 2, args);
5ce0c7
+  caml_raise_with_args (*caml_named_value ("PCRE.Error"), 2, args);
5ce0c7
 }
5ce0c7
 
5ce0c7
 /* Wrap and unwrap pcre regular expression handles, with a finalizer. */
5ce0c7
diff --git a/common/mltools/uri-c.c b/common/mltools/uri-c.c
5ce0c7
index 2a8837cd9..e03647c7b 100644
5ce0c7
--- a/common/mltools/uri-c.c
5ce0c7
+++ b/common/mltools/uri-c.c
5ce0c7
@@ -46,10 +46,8 @@ guestfs_int_mllib_parse_uri (value argv /* arg value, not an array! */)
5ce0c7
   int r;
5ce0c7
 
5ce0c7
   r = parse_uri (String_val (argv), &uri);
5ce0c7
-  if (r == -1) {
5ce0c7
-    value *exn = caml_named_value ("URI.Parse_failed");
5ce0c7
-    caml_raise (*exn);
5ce0c7
-  }
5ce0c7
+  if (r == -1)
5ce0c7
+    caml_raise (*caml_named_value ("URI.Parse_failed"));
5ce0c7
 
5ce0c7
   /* Convert the struct into an OCaml tuple. */
5ce0c7
   rv = caml_alloc_tuple (5);
5ce0c7
diff --git a/common/mlvisit/visit-c.c b/common/mlvisit/visit-c.c
5ce0c7
index 7137c4998..201f6d762 100644
5ce0c7
--- a/common/mlvisit/visit-c.c
5ce0c7
+++ b/common/mlvisit/visit-c.c
5ce0c7
@@ -53,7 +53,6 @@ value
5ce0c7
 guestfs_int_mllib_visit (value gv, value dirv, value fv)
5ce0c7
 {
5ce0c7
   CAMLparam3 (gv, dirv, fv);
5ce0c7
-  value *visit_failure_exn;
5ce0c7
   guestfs_h *g = (guestfs_h *) (intptr_t) Int64_val (gv);
5ce0c7
   struct visitor_function_wrapper_args args;
5ce0c7
   /* The dir string could move around when we call the
5ce0c7
@@ -84,8 +83,7 @@ guestfs_int_mllib_visit (value gv, value dirv, value fv)
5ce0c7
      * already printed the error to stderr (XXX - fix), so we raise a
5ce0c7
      * generic exception.
5ce0c7
      */
5ce0c7
-    visit_failure_exn = caml_named_value ("Visit.Failure");
5ce0c7
-    caml_raise (*visit_failure_exn);
5ce0c7
+    caml_raise (*caml_named_value ("Visit.Failure"));
5ce0c7
   }
5ce0c7
   free (dir);
5ce0c7
 
5ce0c7
-- 
5ce0c7
2.18.4
5ce0c7