ocaml: remove undefined behaviour in systemd_stubs.c
authorWei Liu <wei.liu2@citrix.com>
Mon, 23 Jul 2018 10:26:49 +0000 (11:26 +0100)
committerWei Liu <wei.liu2@citrix.com>
Tue, 24 Jul 2018 08:16:16 +0000 (09:16 +0100)
Clang complains:

systemd_stubs.c:51:8: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
        ret = Val_int(-1U);
              ^~~~~~~~~~~~

Since sd_notify_fd has a signature of unit -> unit, we simply change
the return value to Val_unit.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/ocaml/xenstored/systemd_stubs.c

index 490156c06a46159357209ab7e3d9441a8c024657..31a1a5d384f78da56160958c7c1c18aacb377499 100644 (file)
 CAMLprim value ocaml_sd_notify_ready(value ignore)
 {
        CAMLparam1(ignore);
-       CAMLlocal1(ret);
-
-       ret = Val_int(0);
 
        sd_notify(1, "READY=1");
 
-       CAMLreturn(ret);
+       CAMLreturn(Val_unit);
 }
 
 #else
@@ -46,10 +43,7 @@ CAMLprim value ocaml_sd_notify_ready(value ignore)
 CAMLprim value ocaml_sd_notify_ready(value ignore)
 {
        CAMLparam1(ignore);
-       CAMLlocal1(ret);
-
-       ret = Val_int(-1U);
 
-       CAMLreturn(ret);
+       CAMLreturn(Val_unit);
 }
 #endif