From nobody Tue Apr 23 07:53:28 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 ARC-Seal: i=1; a=rsa-sha256; t=1567688106; cv=none; d=zoho.com; s=zohoarc; b=cWU5M9eRu7yMrF4I4NPRzwF6KJh4w95RPEfn5XdC+vd3CyUtesLmZueZU+xnWLeZQsB8kwOq+5vgbx0QtSS0sa32NspxlrE3tEn9j1bi36rDWwOiu5o7G0lMzdpkKWe9FouTyUbyCVZJ4JVt8BFYRrQJh03T9/xAA2U1XWAbr38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567688106; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=hkPX825r/fykEnSUoBKX8D3aeOMNsuHdC9U2hu0GO4I=; b=B7pQxZHfL6aorpMvzxV0qTbR1r2BGtzlwS4ylwRdabXgbzDxATnd3ezLUEv+go3sqRkyQ/Nf35rmmH5MBEdbvvxPbw4yFcF3IgxmLYIBpOJGcaIpB0cWBSozlLLvWdiMSgM2zxojK/ymGVEkp+6XWa+T4wluqGFmwqq0LcgeQZs= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15676881060891020.8574820170785; Thu, 5 Sep 2019 05:55:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F46E875224; Thu, 5 Sep 2019 12:55:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6FF2100194E; Thu, 5 Sep 2019 12:55:02 +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 3BEE11806B00; Thu, 5 Sep 2019 12:55:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x85Ct02p002681 for ; Thu, 5 Sep 2019 08:55:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40A8460127; Thu, 5 Sep 2019 12:55:00 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CF77600F8; Thu, 5 Sep 2019 12:54:57 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Thu, 5 Sep 2019 14:54:53 +0200 Message-Id: <20190905125453.30307-1-ptoscano@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [ocaml PATCH] Use caml_raise_out_of_memory() where needed. 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Thu, 05 Sep 2019 12:55:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Raise the proper exception on malloc failures. Signed-off-by: Pino Toscano --- libvirt/libvirt_c_oneoffs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index e23c0db..40384e8 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -749,7 +749,7 @@ ocaml_libvirt_domain_get_cpu_stats (value domv) CHECK_ERROR (nparams < 0, "virDomainGetCPUStats"); =20 if ((params =3D malloc(sizeof(*params) * nparams * 128)) =3D=3D NULL) - caml_failwith ("virDomainGetCPUStats: malloc"); + caml_raise_out_of_memory (); =20 cpustats =3D caml_alloc (nr_pcpus, 0); /* cpustats: array of params(list= of typed_param) */ cpu =3D 0; @@ -1461,7 +1461,7 @@ ocaml_libvirt_event_add_timeout (value connv, value m= s, value callback_id) /* Store the int64 callback_id as the opaque data so the OCaml callback can demultiplex to the correct OCaml handler. */ if ((opaque =3D malloc(sizeof(long))) =3D=3D NULL) - caml_failwith ("virEventAddTimeout: malloc"); + caml_raise_out_of_memory (); *((long*)opaque) =3D Int64_val(callback_id); NONBLOCKING(r =3D virEventAddTimeout(Int_val(ms), cb, opaque, freecb)); CHECK_ERROR(r =3D=3D -1, "virEventAddTimeout"); @@ -1551,7 +1551,7 @@ ocaml_libvirt_connect_domain_event_register_any(value= connv, value domv, value c /* Store the int64 callback_id as the opaque data so the OCaml callback can demultiplex to the correct OCaml handler. */ if ((opaque =3D malloc(sizeof(long))) =3D=3D NULL) - caml_failwith ("virConnectDomainEventRegisterAny: malloc"); + caml_raise_out_of_memory (); *((long*)opaque) =3D Int64_val(callback_id); NONBLOCKING(r =3D virConnectDomainEventRegisterAny(conn, dom, eventID, c= b, opaque, freecb)); CHECK_ERROR(r =3D=3D -1, "virConnectDomainEventRegisterAny"); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list