From nobody Thu Apr 25 12:09:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541170953694715.8680610161476; Fri, 2 Nov 2018 08:02:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 950A3C9420; Fri, 2 Nov 2018 15:02:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DF7A60921; Fri, 2 Nov 2018 15:02:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D54F44CA94; Fri, 2 Nov 2018 15:02:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA2EqS2g004317 for ; Fri, 2 Nov 2018 10:52:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E7AE1084293; Fri, 2 Nov 2018 14:52:28 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.246.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5D2B10840CE for ; Fri, 2 Nov 2018 14:52:27 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 15:52:23 +0100 Message-Id: <20181102145223.30849-1-ptoscano@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [ocaml PATCH] Cast virError* enums to int for comparisons with 0 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 02 Nov 2018 15:02:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 rage, 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 --- libvirt/libvirt_c_epilogue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libvirt/libvirt_c_epilogue.c b/libvirt/libvirt_c_epilogue.c index 29656a4..4e75d2f 100644 --- a/libvirt/libvirt_c_epilogue.c +++ b/libvirt/libvirt_c_epilogue.c @@ -153,7 +153,7 @@ Val_err_number (virErrorNumber code) CAMLparam0 (); CAMLlocal1 (rv); =20 - if (0 <=3D code && code <=3D MAX_VIR_CODE) + if (0 <=3D (int) code && code <=3D MAX_VIR_CODE) rv =3D Val_int (code); else { rv =3D caml_alloc (1, 0); /* VIR_ERR_UNKNOWN (code) */ @@ -169,7 +169,7 @@ Val_err_domain (virErrorDomain code) CAMLparam0 (); CAMLlocal1 (rv); =20 - if (0 <=3D code && code <=3D MAX_VIR_DOMAIN) + if (0 <=3D (int) code && code <=3D MAX_VIR_DOMAIN) rv =3D Val_int (code); else { rv =3D caml_alloc (1, 0); /* VIR_FROM_UNKNOWN (code) */ @@ -185,7 +185,7 @@ Val_err_level (virErrorLevel code) CAMLparam0 (); CAMLlocal1 (rv); =20 - if (0 <=3D code && code <=3D MAX_VIR_LEVEL) + if (0 <=3D (int) code && code <=3D MAX_VIR_LEVEL) rv =3D Val_int (code); else { rv =3D caml_alloc (1, 0); /* VIR_ERR_UNKNOWN_LEVEL (code) */ --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list