[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 2/2] ocaml: remove undefined behaviour in systemd_stubs.c

> On 23 Jul 2018, at 10:52, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> On Mon, Jul 23, 2018 at 10:47:04AM +0100, Andrew Cooper wrote:
>> On 23/07/18 10:30, Wei Liu wrote:
>>> Clang complains:
>>> systemd_stubs.c:51:8: error: shifting a negative signed value is undefined 
>>> [-Werror,-Wshift-negative-value]
>>>        ret = Val_int(-1U);
>>>              ^~~~~~~~~~~~
>>> Simply change the return value to 0.
>> That will break the function though, as it previously returned -1.
> I don't think the caller cares about the return value. The function
> signature is unit -> unit for sd_nofity_ready, and the return value is
> not checked at all. I admit I could have misread the code though.
> Wei.

This is correct:

external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"

Any return value can’t be observed on the OCaml side. It is a bit strange 
though that the C code does not return unit accordingly, which would be

return Val_unit;

— C

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.