ocaml-libvirt/0003-Don-t-try-to-memcpy-into-a-String_val.patch
2020-01-19 13:05:59 +00:00

69 lines
2.5 KiB
Diff

From 3d3d6af425d369200a7a62a127adf640d94a38a3 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 19 Jan 2020 13:02:16 +0000
Subject: [PATCH 3/3] Don't try to memcpy into a String_val.
In OCaml 4.10 String_val returns const char *, so we cannot use it as
the destination for memcpy. Use Bytes_val instead.
---
libvirt/generator.pl | 2 +-
libvirt/libvirt_c_oneoffs.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libvirt/generator.pl b/libvirt/generator.pl
index aff371b..463a19b 100755
--- a/libvirt/generator.pl
+++ b/libvirt/generator.pl
@@ -440,7 +440,7 @@ sub gen_c_code
/* UUIDs are byte arrays with a fixed length. */
rv = caml_alloc_string (VIR_UUID_BUFLEN);
- memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
+ memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN);
CAMLreturn (rv);
"
} elsif ($sig =~ /^(\w+) : uuid string$/) {
diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
index fc2ac13..e8472b7 100644
--- a/libvirt/libvirt_c_oneoffs.c
+++ b/libvirt/libvirt_c_oneoffs.c
@@ -394,7 +394,7 @@ ocaml_libvirt_connect_call_auth_default_callback (value listv)
elemv = caml_alloc (2, 0);
if (cred->result != NULL && cred->resultlen > 0) {
v = caml_alloc_string (cred->resultlen);
- memcpy (String_val (v), cred->result, cred->resultlen);
+ memcpy (Bytes_val (v), cred->result, cred->resultlen);
optv = caml_alloc (1, 0);
Store_field (optv, 0, v);
} else
@@ -715,7 +715,7 @@ ocaml_libvirt_domain_get_vcpus (value domv, value maxinfov, value maplenv)
/* Copy the bitmap. */
strv = caml_alloc_string (maxinfo * maplen);
- memcpy (String_val (strv), cpumaps, maxinfo * maplen);
+ memcpy (Bytes_val (strv), cpumaps, maxinfo * maplen);
/* Allocate the tuple and return it. */
rv = caml_alloc_tuple (3);
@@ -900,7 +900,7 @@ ocaml_libvirt_domain_get_all_domain_stats (value connv,
*/
v = caml_alloc_string (VIR_UUID_BUFLEN);
virDomainGetUUID (rstats[i]->dom, uuid);
- memcpy (String_val (v), uuid, VIR_UUID_BUFLEN);
+ memcpy (Bytes_val (v), uuid, VIR_UUID_BUFLEN);
Store_field (dsv, 0, v);
tpv = caml_alloc (rstats[i]->nparams, 0); /* typed_param array */
@@ -1646,7 +1646,7 @@ ocaml_libvirt_secret_get_value (value secv)
CHECK_ERROR (secval == NULL, "virSecretGetValue");
rv = caml_alloc_string (size);
- memcpy (String_val (rv), secval, size);
+ memcpy (Bytes_val (rv), secval, size);
free (secval);
CAMLreturn (rv);
--
2.24.1