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

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