Commit aa571fd5 authored by Pino Toscano's avatar Pino Toscano

Cast virError* enums to int for comparisons with 0

The actual type of an enum in C is implementation defined when there are
no negative values, and thus it can be int, or uint.  This is the case
of the virError* enums in libvirt, as they do not have negative values.

Hence, to avoid hitting tautological comparison errors when checking
their range, temporarly cast the enum values to int when checking they
are not negative.  The check is there to ensure the value is within the
range of the OCaml type used to represent it.
Signed-off-by: Pino Toscano's avatarPino Toscano <ptoscano@redhat.com>
Reviewed-by: 's avatarAndrea Bolognani <abologna@redhat.com>
Reviewed-by: 's avatarRichard W.M. Jones <rjones@redhat.com>
parent 4f58df00
......@@ -153,7 +153,7 @@ Val_err_number (virErrorNumber code)
CAMLparam0 ();
CAMLlocal1 (rv);
if (0 <= code && code <= MAX_VIR_CODE)
if (0 <= (int) code && code <= MAX_VIR_CODE)
rv = Val_int (code);
else {
rv = caml_alloc (1, 0); /* VIR_ERR_UNKNOWN (code) */
......@@ -169,7 +169,7 @@ Val_err_domain (virErrorDomain code)
CAMLparam0 ();
CAMLlocal1 (rv);
if (0 <= code && code <= MAX_VIR_DOMAIN)
if (0 <= (int) code && code <= MAX_VIR_DOMAIN)
rv = Val_int (code);
else {
rv = caml_alloc (1, 0); /* VIR_FROM_UNKNOWN (code) */
......@@ -185,7 +185,7 @@ Val_err_level (virErrorLevel code)
CAMLparam0 ();
CAMLlocal1 (rv);
if (0 <= code && code <= MAX_VIR_LEVEL)
if (0 <= (int) code && code <= MAX_VIR_LEVEL)
rv = Val_int (code);
else {
rv = caml_alloc (1, 0); /* VIR_ERR_UNKNOWN_LEVEL (code) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment