Blame SOURCES/0001-Use-safe-string-and-fix-the-library.patch

ca920e
From bab7f84ade84ceaddb08b6948792d49b3d04b897 Mon Sep 17 00:00:00 2001
ca920e
From: "Richard W.M. Jones" <rjones@redhat.com>
ca920e
Date: Wed, 8 Nov 2017 16:52:58 +0000
ca920e
Subject: [PATCH] Use -safe-string and fix the library.
ca920e
ca920e
Note this changes the type of the cpumap from string to bytes,
ca920e
since (by the design of the API) it must be mutated.
ca920e
---
ca920e
 libvirt/Makefile.in |  4 ++--
ca920e
 libvirt/libvirt.ml  | 10 +++++-----
ca920e
 libvirt/libvirt.mli |  6 +++---
ca920e
 3 files changed, 10 insertions(+), 10 deletions(-)
ca920e
ca920e
diff --git a/libvirt/Makefile.in b/libvirt/Makefile.in
ca920e
index cf614fc..1eb846b 100644
ca920e
--- a/libvirt/Makefile.in
ca920e
+++ b/libvirt/Makefile.in
ca920e
@@ -31,11 +31,11 @@ OCAMLMKLIB	= @OCAMLMKLIB@
ca920e
 
ca920e
 ifneq ($(OCAMLFIND),)
ca920e
 OCAMLCPACKAGES	:= -package unix
ca920e
-OCAMLCFLAGS	:= -g -warn-error CDEFLMPSUVYZX-3
ca920e
+OCAMLCFLAGS	:= -g -warn-error CDEFLMPSUVYZX-3 -safe-string
ca920e
 OCAMLCLIBS	:= -linkpkg
ca920e
 else
ca920e
 OCAMLCINCS	:=
ca920e
-OCAMLCFLAGS	:= -g -warn-error CDEFLMPSUVYZX-3
ca920e
+OCAMLCFLAGS	:= -g -warn-error CDEFLMPSUVYZX-3 -safe-string
ca920e
 OCAMLCLIBS	:= unix.cma
ca920e
 endif
ca920e
 
ca920e
diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml
ca920e
index d03a127..7e1e470 100644
ca920e
--- a/libvirt/libvirt.ml
ca920e
+++ b/libvirt/libvirt.ml
ca920e
@@ -92,13 +92,13 @@ struct
ca920e
 
ca920e
   (* See VIR_USE_CPU, VIR_UNUSE_CPU, VIR_CPU_USABLE macros defined in <libvirt.h>. *)
ca920e
   let use_cpu cpumap cpu =
ca920e
-    cpumap.[cpu/8] <-
ca920e
-      Char.chr (Char.code cpumap.[cpu/8] lor (1 lsl (cpu mod 8)))
ca920e
+    Bytes.set cpumap (cpu/8)
ca920e
+      (Char.chr (Char.code (Bytes.get cpumap (cpu/8)) lor (1 lsl (cpu mod 8))))
ca920e
   let unuse_cpu cpumap cpu =
ca920e
-    cpumap.[cpu/8] <-
ca920e
-      Char.chr (Char.code cpumap.[cpu/8] land (lnot (1 lsl (cpu mod 8))))
ca920e
+    Bytes.set cpumap (cpu/8)
ca920e
+      (Char.chr (Char.code (Bytes.get cpumap (cpu/8)) land (lnot (1 lsl (cpu mod 8)))))
ca920e
   let cpu_usable cpumaps maplen vcpu cpu =
ca920e
-    Char.code cpumaps.[vcpu*maplen + cpu/8] land (1 lsl (cpu mod 8)) <> 0
ca920e
+    Char.code (Bytes.get cpumaps (vcpu*maplen + cpu/8)) land (1 lsl (cpu mod 8)) <> 0
ca920e
 
ca920e
   external set_keep_alive : [>`R] t -> int -> int -> unit = "ocaml_libvirt_connect_set_keep_alive"
ca920e
 
ca920e
diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli
ca920e
index dc0033b..87f50f5 100644
ca920e
--- a/libvirt/libvirt.mli
ca920e
+++ b/libvirt/libvirt.mli
ca920e
@@ -376,11 +376,11 @@ sig
ca920e
 	CPU map between a single virtual and all physical CPUs of a domain.
ca920e
     *)
ca920e
 
ca920e
-  val use_cpu : string -> int -> unit
ca920e
+  val use_cpu : bytes -> int -> unit
ca920e
     (** [use_cpu cpumap cpu] marks [cpu] as usable in [cpumap]. *)
ca920e
-  val unuse_cpu : string -> int -> unit
ca920e
+  val unuse_cpu : bytes -> int -> unit
ca920e
     (** [unuse_cpu cpumap cpu] marks [cpu] as not usable in [cpumap]. *)
ca920e
-  val cpu_usable : string -> int -> int -> int -> bool
ca920e
+  val cpu_usable : bytes -> int -> int -> int -> bool
ca920e
     (** [cpu_usable cpumaps maplen vcpu cpu] checks returns true iff the
ca920e
 	[cpu] is usable by [vcpu]. *)
ca920e
 
ca920e
-- 
ca920e
2.13.1
ca920e