From nobody Mon Feb 9 15:08:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1579439104; cv=none; d=zohomail.com; s=zohoarc; b=mhop2U1Wy7JmVUG/Ov6Hi5Rnk4XY9Xg7xT5MaOrcs/b2VBXK/F+gfWzAsV60gbXamPeK56mJbQMxueRQ7hetnZHres9OTXObBHQc0podWuYUPuOa3Y5AIw8lg2APujbNNpUftGaEwvLlSqfektFuBLdqFJnEr6RTjGqQSN+FmFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579439104; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i0xofss+6S5HaPFl22O21+zh7GE17FCEYyEbEV2Mq3Q=; b=JCJrw+/eZnc285tnSuDlZui/u8mzKblVPclmxmLiXjqEKynYP1PwwgIJbHwdNYj+dIUw42+t4Q4cQ4TfP+ktqgDsElA8qN+0lKcV+6nD1z9pFaoEKd9dKIDmg5hKPuarTdIEEmH8Ed4alyzpJSnxeLwUMm6/XK4eexOEp0uYIIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1579439104945553.5004249623951; Sun, 19 Jan 2020 05:05:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-xRBZWbqxMS2ld3Wq3MBYfg-1; Sun, 19 Jan 2020 08:05:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E81871005514; Sun, 19 Jan 2020 13:04:55 +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 C210F60F82; Sun, 19 Jan 2020 13:04:55 +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 81439180202B; Sun, 19 Jan 2020 13:04:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00JD4JaR001293 for ; Sun, 19 Jan 2020 08:04:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 31F4D89E7B; Sun, 19 Jan 2020 13:04:19 +0000 (UTC) Received: from foo.home.annexia.org (ovpn-117-237.ams2.redhat.com [10.36.117.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BE7489D17; Sun, 19 Jan 2020 13:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579439103; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=i0xofss+6S5HaPFl22O21+zh7GE17FCEYyEbEV2Mq3Q=; b=DDInkfzFfVzUAORM7WSXeZXxjzJUrO/6Fg1WAFRNqPXFRm4Kb6rq68L5US52HnxdUaXJKa aYyT3Tm6vYkye7qxLrOaFgIysW1acZF/lonrWz1jEObIqLfs2QO/lO8fj+eJ9uY+VWhYR/ /xVmQIWkeMXgp8OzpKLr2RhonSMFo+s= From: "Richard W.M. Jones" To: libvir-list@redhat.com Subject: [PATCH ocaml 3/3] Don't try to memcpy into a String_val. Date: Sun, 19 Jan 2020 13:04:10 +0000 Message-Id: <20200119130410.3348835-4-rjones@redhat.com> In-Reply-To: <20200119130410.3348835-1-rjones@redhat.com> References: <20200119130410.3348835-1-rjones@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: ptoscano@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: xRBZWbqxMS2ld3Wq3MBYfg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In OCaml 4.10 String_val returns const char *, so we cannot use it as the destination for memcpy. Use Bytes_val instead. --- libvirt/generator.pl | 2 +- libvirt/libvirt_c_oneoffs.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libvirt/generator.pl b/libvirt/generator.pl index aff371b..463a19b 100755 --- a/libvirt/generator.pl +++ b/libvirt/generator.pl @@ -440,7 +440,7 @@ sub gen_c_code =20 /* UUIDs are byte arrays with a fixed length. */ rv =3D caml_alloc_string (VIR_UUID_BUFLEN); - memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); + memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); " } elsif ($sig =3D~ /^(\w+) : uuid string$/) { diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index fc2ac13..e8472b7 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -394,7 +394,7 @@ ocaml_libvirt_connect_call_auth_default_callback (value= listv) elemv =3D caml_alloc (2, 0); if (cred->result !=3D NULL && cred->resultlen > 0) { v =3D caml_alloc_string (cred->resultlen); - memcpy (String_val (v), cred->result, cred->resultlen); + memcpy (Bytes_val (v), cred->result, cred->resultlen); optv =3D caml_alloc (1, 0); Store_field (optv, 0, v); } else @@ -715,7 +715,7 @@ ocaml_libvirt_domain_get_vcpus (value domv, value maxin= fov, value maplenv) =20 /* Copy the bitmap. */ strv =3D caml_alloc_string (maxinfo * maplen); - memcpy (String_val (strv), cpumaps, maxinfo * maplen); + memcpy (Bytes_val (strv), cpumaps, maxinfo * maplen); =20 /* Allocate the tuple and return it. */ rv =3D caml_alloc_tuple (3); @@ -900,7 +900,7 @@ ocaml_libvirt_domain_get_all_domain_stats (value connv, */ v =3D caml_alloc_string (VIR_UUID_BUFLEN); virDomainGetUUID (rstats[i]->dom, uuid); - memcpy (String_val (v), uuid, VIR_UUID_BUFLEN); + memcpy (Bytes_val (v), uuid, VIR_UUID_BUFLEN); Store_field (dsv, 0, v); =20 tpv =3D caml_alloc (rstats[i]->nparams, 0); /* typed_param array */ @@ -1646,7 +1646,7 @@ ocaml_libvirt_secret_get_value (value secv) CHECK_ERROR (secval =3D=3D NULL, "virSecretGetValue"); =20 rv =3D caml_alloc_string (size); - memcpy (String_val (rv), secval, size); + memcpy (Bytes_val (rv), secval, size); free (secval); =20 CAMLreturn (rv); --=20 2.24.1