From nobody Wed May 1 14:13:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1579439073; cv=none; d=zohomail.com; s=zohoarc; b=BPosSS9TR2SzNMgdjHcUu+SvlcCd8EqBBOLi9EjsKfoQLKb2btNmhdq4dMbK5uxHuYHxvJ1pr5OF3pl/L0COyS+o5FcHmFRnN2Krd2WBI404lnS/fF4rqVoDntqwKqiWqRvvpGuloDDtuvtYIY33ZtCH3Mi41E0zlld8tIfmG74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579439073; 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=BqrCBtVWq/FEKPAMinJFSaJ+HvQkbiatkJjGa3nNnKQ=; b=oEZ0ekscqTbe6UZ1pqwflsO+9hwOzLdwh+0O3wK3kWS0Sy47NxSrG8cbNaLrkwdIuGtFxfum5rqSJpVKrGyu1q6nOp2979cWc02Zvpy0RcG8e4nkGhxkwwT0mwI0FcFf8QkS+iCosqdrHZ+s0MG3eaTufJ7RgfURMkByc7ZLnEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1579439073614667.226756570041; Sun, 19 Jan 2020 05:04:33 -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-208-kuhN0Tg4MDiA2ZMng4JB0g-1; Sun, 19 Jan 2020 08:04:30 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 122A9185432D; Sun, 19 Jan 2020 13:04:24 +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 5895328D13; Sun, 19 Jan 2020 13:04:23 +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 69E961802027; Sun, 19 Jan 2020 13:04:18 +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 00JD4HjW001280 for ; Sun, 19 Jan 2020 08:04:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1B12089E7B; Sun, 19 Jan 2020 13:04:17 +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 62CF189D17; Sun, 19 Jan 2020 13:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579439072; 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=BqrCBtVWq/FEKPAMinJFSaJ+HvQkbiatkJjGa3nNnKQ=; b=GbMSXWwoEfiJeNQYbztTZ2HmwwbDB5uKqcabehEwWhONpQLTI2jLtFe9VePNn34vTobc0G Sna7Hi1UsEUZ+cy0rz1m4PO5yEOLffetkekLaZ8EFyrymuh9z76MAghcSvabEKt9XKFoj2 iivzwlhNf3ECSX60wu85zwgfRhsdc3M= From: "Richard W.M. Jones" To: libvir-list@redhat.com Subject: [PATCH ocaml 1/3] block_peek, memory_peek: Use bytes for return buffer. Date: Sun, 19 Jan 2020 13:04:08 +0000 Message-Id: <20200119130410.3348835-2-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.84 on 10.5.11.23 X-MC-Unique: kuhN0Tg4MDiA2ZMng4JB0g-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" Strings are immutable in modern OCaml. --- libvirt/libvirt.ml | 4 ++-- libvirt/libvirt.mli | 4 ++-- libvirt/libvirt_c_oneoffs.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml index 7f9d0e4..bdb9460 100644 --- a/libvirt/libvirt.ml +++ b/libvirt/libvirt.ml @@ -731,8 +731,8 @@ struct external migrate : [>`W] t -> [>`W] Connect.t -> migrate_flag list -> ?d= name:string -> ?uri:string -> ?bandwidth:int -> unit -> rw t =3D "ocaml_lib= virt_domain_migrate_bytecode" "ocaml_libvirt_domain_migrate_native" external block_stats : [>`R] t -> string -> block_stats =3D "ocaml_libvi= rt_domain_block_stats" external interface_stats : [>`R] t -> string -> interface_stats =3D "oca= ml_libvirt_domain_interface_stats" - external block_peek : [>`W] t -> string -> int64 -> int -> string -> int= -> unit =3D "ocaml_libvirt_domain_block_peek_bytecode" "ocaml_libvirt_doma= in_block_peek_native" - external memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> st= ring -> int -> unit =3D "ocaml_libvirt_domain_memory_peek_bytecode" "ocaml_= libvirt_domain_memory_peek_native" + external block_peek : [>`W] t -> string -> int64 -> int -> bytes -> int = -> unit =3D "ocaml_libvirt_domain_block_peek_bytecode" "ocaml_libvirt_domai= n_block_peek_native" + external memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> by= tes -> int -> unit =3D "ocaml_libvirt_domain_memory_peek_bytecode" "ocaml_l= ibvirt_domain_memory_peek_native" =20 external get_all_domain_stats : [>`R] Connect.t -> stats_type list -> ge= t_all_domain_stats_flag list -> domain_stats_record array =3D "ocaml_libvir= t_domain_get_all_domain_stats" =20 diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli index 0d74199..7900392 100644 --- a/libvirt/libvirt.mli +++ b/libvirt/libvirt.mli @@ -708,7 +708,7 @@ sig val interface_stats : [>`R] t -> string -> interface_stats (** Returns network interface stats. *) =20 - val block_peek : [>`W] t -> string -> int64 -> int -> string -> int -> u= nit + val block_peek : [>`W] t -> string -> int64 -> int -> bytes -> int -> un= it (** [block_peek dom path offset size buf boff] reads [size] bytes at [offset] in the domain's [path] block device. =20 @@ -717,7 +717,7 @@ sig =20 See also {!max_peek}. *) val memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> - string -> int -> unit + bytes -> int -> unit (** [memory_peek dom Virtual offset size] reads [size] bytes at [offset] in the domain's virtual memory. =20 diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index 40384e8..8468c73 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -1057,7 +1057,7 @@ ocaml_libvirt_domain_block_peek_native (value domv, v= alue pathv, value offsetv, const char *path =3D String_val (pathv); unsigned long long offset =3D Int64_val (offsetv); size_t size =3D Int_val (sizev); - char *buffer =3D String_val (bufferv); + unsigned char *buffer =3D Bytes_val (bufferv); int boff =3D Int_val (boffv); int r; =20 @@ -1089,7 +1089,7 @@ ocaml_libvirt_domain_memory_peek_native (value domv, = value flagsv, value offsetv int flags =3D 0; unsigned long long offset =3D Int64_val (offsetv); size_t size =3D Int_val (sizev); - char *buffer =3D String_val (bufferv); + unsigned char *buffer =3D Bytes_val (bufferv); int boff =3D Int_val (boffv); int r; =20 --=20 2.24.1 From nobody Wed May 1 14:13:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1579439101; cv=none; d=zohomail.com; s=zohoarc; b=nlRtHcM+mYRbd/wk2iwOzZXg20snIifygMOnuNH4Fc/yUk6ImfH5QCsjlosNOAeAvKz05yXy1qk26m5yGuQgI2kg/eaRJvFbiVbTSLbwqQjUA2UgVDR7PjJAgZYtGncNBA2RRY/Pe7UuJHtKFyBgwr0Ad/yYkmhfVkYxhkYjpuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579439101; 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=JwdM6c9X9PtZFXD1kJdrwFZDzNvcN7tBxQcOtonNdaY=; b=K4DPsE70WGCcZP5aPfdHn7/03FJu3nVdmigzpwDbjkGKtNIU+cjjENxrm+UckfYJko9R1dmn+rfaj5Zo0lMc3xFndM0nvUgLfK17PJ3toIFiCMXFqWfkymieWvkDJoHNazppj7xbkEsrxe1p8vY7ynFEB+KzXKeQniDlv5Yr8ac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1579439101110262.4573688676403; Sun, 19 Jan 2020 05:05:01 -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-408-d-MbEBw_PlCX9IjYeZveYA-1; Sun, 19 Jan 2020 08:04:56 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0DBC185432C; Sun, 19 Jan 2020 13:04:50 +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 931BC1084393; Sun, 19 Jan 2020 13:04:50 +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 1C1141802029; Sun, 19 Jan 2020 13:04:50 +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 00JD4I2f001285 for ; Sun, 19 Jan 2020 08:04:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 29C0089E7B; Sun, 19 Jan 2020 13:04:18 +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 6F5C289D17; Sun, 19 Jan 2020 13:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579439100; 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=JwdM6c9X9PtZFXD1kJdrwFZDzNvcN7tBxQcOtonNdaY=; b=AHJ3yH0HxzWi2Qw3fcDB6wjCJX7dI9fli/MrNLPWgv5CZqt4oo5NvxEZ4UywjyyedqCYQn IsSZvvvGVOW8o8BhwzKLHUHgGAExEfjv+TR0DE0jbpEa/VmKBxSKoFFDQboXutfsnCc3UL dKctvOffk6pBVF+iJMkHgbQsk6YVGoY= From: "Richard W.M. Jones" To: libvir-list@redhat.com Subject: [PATCH ocaml 2/3] String_val returns const char * in OCaml 4.10. Date: Sun, 19 Jan 2020 13:04:09 +0000 Message-Id: <20200119130410.3348835-3-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.84 on 10.5.11.22 X-MC-Unique: d-MbEBw_PlCX9IjYeZveYA-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" This should be compatible with earlier versions of OCaml too since we are just assigning a char * to a const char *. --- libvirt/generator.pl | 14 +++++++------- libvirt/libvirt_c_oneoffs.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libvirt/generator.pl b/libvirt/generator.pl index ac3dd65..aff371b 100755 --- a/libvirt/generator.pl +++ b/libvirt/generator.pl @@ -593,7 +593,7 @@ sub gen_c_code } elsif ($sig =3D~ /^(\w+), string : unit$/) { "\ " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); int r; =20 NONBLOCKING (r =3D $c_name ($1, str)); @@ -605,7 +605,7 @@ sub gen_c_code "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); int r; =20 NONBLOCKING (r =3D $c_name ($1, str, 0)); @@ -618,7 +618,7 @@ sub gen_c_code "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); $c_ret_type r; =20 NONBLOCKING (r =3D $c_name ($1, str)); @@ -633,7 +633,7 @@ sub gen_c_code "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); $c_ret_type r; =20 NONBLOCKING (r =3D $c_name ($1, str, 0)); @@ -648,7 +648,7 @@ sub gen_c_code "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); unsigned int u =3D Int_val (uv); $c_ret_type r; =20 @@ -735,7 +735,7 @@ sub gen_c_code "\ CAMLlocal2 (rv, connv); " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); $c_ret_type r; =20 NONBLOCKING (r =3D $c_name ($1, str)); @@ -751,7 +751,7 @@ sub gen_c_code "\ CAMLlocal2 (rv, connv); " . gen_unpack_args ($1) . " - char *str =3D String_val (strv); + const char *str =3D String_val (strv); $c_ret_type r; =20 NONBLOCKING (r =3D $c_name ($1, str, 0)); diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index 8468c73..fc2ac13 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -601,7 +601,7 @@ ocaml_libvirt_domain_set_scheduler_parameters (value do= mv, value paramsv) int nparams =3D Wosize_val (paramsv); virSchedParameterPtr params; int r, i; - char *name; + const char *name; =20 params =3D malloc (sizeof (*params) * nparams); if (params =3D=3D NULL) @@ -1005,7 +1005,7 @@ ocaml_libvirt_domain_block_stats (value domv, value p= athv) CAMLparam2 (domv, pathv); CAMLlocal2 (rv,v); virDomainPtr dom =3D Domain_val (domv); - char *path =3D String_val (pathv); + const char *path =3D String_val (pathv); struct _virDomainBlockStats stats; int r; =20 @@ -1028,7 +1028,7 @@ ocaml_libvirt_domain_interface_stats (value domv, val= ue pathv) CAMLparam2 (domv, pathv); CAMLlocal2 (rv,v); virDomainPtr dom =3D Domain_val (domv); - char *path =3D String_val (pathv); + const char *path =3D String_val (pathv); struct _virDomainInterfaceStats stats; int r; =20 --=20 2.24.1 From nobody Wed May 1 14:13:32 2024 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