]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
oxenstored: fix error when shifting negative value
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 26 Apr 2016 10:07:51 +0000 (12:07 +0200)
committerWei Liu <wei.liu2@citrix.com>
Wed, 27 Apr 2016 13:14:18 +0000 (14:14 +0100)
By explicitly casting it to unsigned.

Reasoning on why this is needed, provided by Andrew Cooper:

"Ocaml stores integers shifted left by one, and with the bottom bit set.

Values with the bottom bit clear are pointers into the GC'd heap. Values
with the bottom bit set are integers, and need to be shifted by 1 bit to
have calculations performed."

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
tools/ocaml/xenstored/systemd_stubs.c

index 1bd5deaf53d17bad820ba1bd27d0ddc788081051..a78a72b75c2c0427ef44baa33405bd6cb41d4c19 100644 (file)
@@ -124,7 +124,7 @@ CAMLprim value ocaml_sd_listen_fds(value connect_to)
        CAMLparam1(connect_to);
        CAMLlocal1(sock_ret);
 
-       sock_ret = Val_int(-1);
+       sock_ret = Val_int(-1U);
 
        CAMLreturn(sock_ret);
 }
@@ -144,7 +144,7 @@ CAMLprim value ocaml_sd_notify_ready(value ignore)
        CAMLparam1(ignore);
        CAMLlocal1(ret);
 
-       ret = Val_int(-1);
+       ret = Val_int(-1U);
 
        CAMLreturn(ret);
 }