[libvirt] [ocaml PATCH] Make const the return value of caml_named_value()

Pino Toscano posted 1 patch 4 years, 6 months ago
Failed in applying to current master (apply log)
libvirt/libvirt_c_oneoffs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[libvirt] [ocaml PATCH] Make const the return value of caml_named_value()
Posted by Pino Toscano 4 years, 6 months ago
With OCaml >= 4.09 caml_named_value() returns a const value *, so keep
the constness to build also in this case.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
---
 libvirt/libvirt_c_oneoffs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
index 6f56f10..e23c0db 100644
--- a/libvirt/libvirt_c_oneoffs.c
+++ b/libvirt/libvirt_c_oneoffs.c
@@ -1207,7 +1207,7 @@ ocaml_libvirt_event_run_default_impl (value unitv)
 #define DOMAIN_CALLBACK_BEGIN(NAME)                              \
   value connv, domv, callback_id, result;                        \
   connv = domv = callback_id = result = Val_int(0);              \
-  static value *callback = NULL;                                 \
+  static const value *callback = NULL;                           \
   caml_leave_blocking_section();                                 \
   if (callback == NULL)                                          \
     callback = caml_named_value(NAME);                           \
@@ -1433,7 +1433,7 @@ timeout_callback(int timer, void *opaque)
 {
   value callback_id, result;
   callback_id = result = Val_int(0);
-  static value *callback = NULL;
+  static const value *callback = NULL;
   caml_leave_blocking_section();
   if (callback == NULL)
     callback = caml_named_value("Libvirt.timeout_callback");
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ocaml PATCH] Make const the return value of caml_named_value()
Posted by Richard W.M. Jones 4 years, 6 months ago
On Thu, Sep 05, 2019 at 09:59:48AM +0200, Pino Toscano wrote:
> With OCaml >= 4.09 caml_named_value() returns a const value *, so keep
> the constness to build also in this case.
> 
> Signed-off-by: Pino Toscano <ptoscano@redhat.com>
> ---
>  libvirt/libvirt_c_oneoffs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
> index 6f56f10..e23c0db 100644
> --- a/libvirt/libvirt_c_oneoffs.c
> +++ b/libvirt/libvirt_c_oneoffs.c
> @@ -1207,7 +1207,7 @@ ocaml_libvirt_event_run_default_impl (value unitv)
>  #define DOMAIN_CALLBACK_BEGIN(NAME)                              \
>    value connv, domv, callback_id, result;                        \
>    connv = domv = callback_id = result = Val_int(0);              \
> -  static value *callback = NULL;                                 \
> +  static const value *callback = NULL;                           \
>    caml_leave_blocking_section();                                 \
>    if (callback == NULL)                                          \
>      callback = caml_named_value(NAME);                           \
> @@ -1433,7 +1433,7 @@ timeout_callback(int timer, void *opaque)
>  {
>    value callback_id, result;
>    callback_id = result = Val_int(0);
> -  static value *callback = NULL;
> +  static const value *callback = NULL;
>    caml_leave_blocking_section();
>    if (callback == NULL)
>      callback = caml_named_value("Libvirt.timeout_callback");

ACK

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list