]> xenbits.xensource.com Git - xen.git/commit
tools/ocaml: Fix stubs build when OCaml has been compiled with -safe-string
authorJulien Grall <jgrall@amazon.com>
Mon, 30 Mar 2020 14:14:23 +0000 (15:14 +0100)
committerJulien Grall <jgrall@amazon.com>
Mon, 20 Apr 2020 14:03:13 +0000 (15:03 +0100)
commit59b087e3954402c487e0abb4ad9bd05f43669436
treee1721cb6cffddb6a9e489a7328a42a648b3d9fc3
parent78686437e949a85a207ae1a0d637efe2d3778bbe
tools/ocaml: Fix stubs build when OCaml has been compiled with -safe-string

The OCaml code has been fixed to handle properly -safe-string in Xen
4.11, however the stubs part were missed.

On OCaml newer than 4.06.1, String_Val() will return a const char *
when using -safe-string leading to build failure when this is used
in place where char * is expected.

The main use in Xen code base is when a new string is allocated. The
suggested approach by the OCaml community [1] is to use the helper
caml_alloc_initialized_string() but it was introduced by OCaml 4.06.1.

The next best approach is to cast String_val() to (char *) as the helper
would have done. So use it when we need to update the new string using
memcpy().

Take the opportunity to remove the unnecessary cast of the source as
mempcy() is expecting a void *.

[1] https://github.com/ocaml/ocaml/pull/1274

Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/libs/xb/xenbus_stubs.c
tools/ocaml/libs/xc/xenctrl_stubs.c