From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741583144434.21584010996594; Thu, 22 Dec 2022 12:39:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJO-0004r5-7M; Thu, 22 Dec 2022 15:37:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJM-0004pl-5y for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:04 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJK-0002KW-Fp for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:03 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 7C717CED23; Thu, 22 Dec 2022 21:36:56 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 01/12] libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU Date: Thu, 22 Dec 2022 21:36:40 +0100 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741583517100001 Then the libvhost-user sources are used by another project, it can not be guaranteed that _GNU_SOURCE is set by the build system. If it is for example not set, errors like this show up. CC libvhost-user.o libvhost-user.c: In function =E2=80=98vu_panic=E2=80=99: libvhost-user.c:195:9: error: implicit declaration of function =E2=80=98vas= printf=E2=80=99; did you mean =E2=80=98vsprintf=E2=80=99? [-Werror=3Dimplic= it-function-declaration] 195 | if (vasprintf(&buf, msg, ap) < 0) { | ^~~~~~~~~ | vsprintf The simplest way to allow external complication of libvhost-user.[ch] is by setting _GNU_SOURCE if it is not already set by the build system. Signed-off-by: Marcel Holtmann Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index d6ee6e7d9168..b55b9e244d9a 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -13,6 +13,10 @@ * later. See the COPYING file in the top-level directory. */ =20 +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + /* this code avoids GLib dependency */ #include #include --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741556079205.54744864959525; Thu, 22 Dec 2022 12:39:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJN-0004qC-Nf; Thu, 22 Dec 2022 15:37:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJM-0004pq-A8 for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:04 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJK-0002KX-G1 for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:04 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id B8AC1CED24; Thu, 22 Dec 2022 21:36:56 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 02/12] libvhost-user: Replace typeof with __typeof__ Date: Thu, 22 Dec 2022 21:36:41 +0100 Message-Id: <981aa822bcaaa2b8d74f245339a99a85c25b346f.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741557392100001 Strictly speaking only -std=3Dgnu99 support the usage of typeof and for easier inclusion in external projects, it is better to use __typeof__. CC libvhost-user.o libvhost-user.c: In function =E2=80=98vu_log_queue_fill=E2=80=99: libvhost-user.c:86:13: error: implicit declaration of function =E2=80=98typ= eof=E2=80=99 [-Werror=3Dimplicit-function-declaration] 86 | typeof(x) _min1 =3D (x); \ | ^~~~~~ Changing these two users of typeof makes the compiler happy and no extra flags or pragmas need to be provided. Signed-off-by: Marcel Holtmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index b55b9e244d9a..67d75ece53b7 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -62,8 +62,8 @@ #endif /* !__GNUC__ */ #ifndef MIN #define MIN(x, y) ({ \ - typeof(x) _min1 =3D (x); \ - typeof(y) _min2 =3D (y); \ + __typeof__(x) _min1 =3D (x); \ + __typeof__(y) _min2 =3D (y); \ (void) (&_min1 =3D=3D &_min2); \ _min1 < _min2 ? _min1 : _min2; }) #endif --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741450373446.84070629195446; Thu, 22 Dec 2022 12:37:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJP-0004s2-CK; Thu, 22 Dec 2022 15:37:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJN-0004qD-DC for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:05 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJK-0002Kb-G2 for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:05 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id EE9ADCED25; Thu, 22 Dec 2022 21:36:56 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 03/12] libvhost-user: Cast rc variable to avoid compiler warning Date: Thu, 22 Dec 2022 21:36:42 +0100 Message-Id: <7a791e27b7bd3e0a8b8cc8fbb15090a870d226d5.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741450958100001 The assert from recvmsg() return value against an uint32_t size field from a protocol struct throws a compiler warning. CC libvhost-user.o In file included from libvhost-user.c:27: libvhost-user.c: In function =E2=80=98vu_message_read_default=E2=80=99: libvhost-user.c:363:19: error: comparison of integer expressions of differe= nt signedness: =E2=80=98int=E2=80=99 and =E2=80=98uint32_t=E2=80=99 {aka = =E2=80=98unsigned int=E2=80=99} [-Werror=3Dsign-compare] 363 | assert(rc =3D=3D vmsg->size); | ^~ This is not critical, but annoying when the libvhost-user source are used in an external project that has this compiler warning switched on. Signed-off-by: Marcel Holtmann Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 67d75ece53b7..bcdf32a24f60 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -339,7 +339,7 @@ vu_message_read_default(VuDev *dev, int conn_fd, VhostU= serMsg *vmsg) goto fail; } =20 - assert(rc =3D=3D vmsg->size); + assert((uint32_t)rc =3D=3D vmsg->size); } =20 return true; --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741677849704.8901010773316; Thu, 22 Dec 2022 12:41:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJP-0004sZ-WA; Thu, 22 Dec 2022 15:37:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJN-0004qE-E8 for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:05 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJK-0002Kg-Fq for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:05 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 4874BCED26; Thu, 22 Dec 2022 21:36:57 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 04/12] libvhost-user: Use unsigned int i for some for-loop iterations Date: Thu, 22 Dec 2022 21:36:43 +0100 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741679864100003 The sign-compare warning also hits some of the for-loops, but it easy fixed by just making the iterator variable unsigned int. CC libvhost-user.o libvhost-user.c: In function =E2=80=98vu_gpa_to_va=E2=80=99: libvhost-user.c:223:19: error: comparison of integer expressions of differe= nt signedness: =E2=80=98int=E2=80=99 and =E2=80=98uint32_t=E2=80=99 {aka = =E2=80=98unsigned int=E2=80=99} [-Werror=3Dsign-compare] 223 | for (i =3D 0; i < dev->nregions; i++) { | ^ Signed-off-by: Marcel Holtmann Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index bcdf32a24f60..211d31a4cc88 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -192,7 +192,7 @@ vu_panic(VuDev *dev, const char *msg, ...) void * vu_gpa_to_va(VuDev *dev, uint64_t *plen, uint64_t guest_addr) { - int i; + unsigned int i; =20 if (*plen =3D=3D 0) { return NULL; @@ -218,7 +218,7 @@ vu_gpa_to_va(VuDev *dev, uint64_t *plen, uint64_t guest= _addr) static void * qva_to_va(VuDev *dev, uint64_t qemu_addr) { - int i; + unsigned int i; =20 /* Find matching memory region. */ for (i =3D 0; i < dev->nregions; i++) { @@ -621,7 +621,7 @@ map_ring(VuDev *dev, VuVirtq *vq) =20 static bool generate_faults(VuDev *dev) { - int i; + unsigned int i; for (i =3D 0; i < dev->nregions; i++) { VuDevRegion *dev_region =3D &dev->regions[i]; int ret; @@ -829,7 +829,7 @@ static inline bool reg_equal(VuDevRegion *vudev_reg, static bool vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { VhostUserMemoryRegion m =3D vmsg->payload.memreg.region, *msg_region = =3D &m; - int i; + unsigned int i; bool found =3D false; =20 if (vmsg->fd_num > 1) { @@ -895,7 +895,7 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { static bool vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg) { - int i; + unsigned int i; VhostUserMemory m =3D vmsg->payload.memory, *memory =3D &m; dev->nregions =3D memory->nregions; =20 @@ -972,7 +972,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg= *vmsg) static bool vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg) { - int i; + unsigned int i; VhostUserMemory m =3D vmsg->payload.memory, *memory =3D &m; =20 for (i =3D 0; i < dev->nregions; i++) { @@ -1980,7 +1980,7 @@ end: void vu_deinit(VuDev *dev) { - int i; + unsigned int i; =20 for (i =3D 0; i < dev->nregions; i++) { VuDevRegion *r =3D &dev->regions[i]; --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741764721351.9080741270193; Thu, 22 Dec 2022 12:42:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJP-0004sY-TD; Thu, 22 Dec 2022 15:37:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJO-0004r4-CD for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJM-0002LE-Ma for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:05 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 9E834CED27; Thu, 22 Dec 2022 21:36:57 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 05/12] libvhost-user: Declare uffdio_register early to make it C90 compliant Date: Thu, 22 Dec 2022 21:36:44 +0100 Message-Id: <556c2d00c01fa134d13c0371d4014c90694c2943.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741766565100001 When using libvhost-user source in an external project that wants to comply with the C90 standard, it is best to declare variables before code. CC libvhost-user.o libvhost-user.c: In function =E2=80=98generate_faults=E2=80=99: libvhost-user.c:683:9: error: ISO C90 forbids mixed declarations and code [= -Werror=3Ddeclaration-after-statement] 683 | struct uffdio_register reg_struct; | ^~~~~~ In this case, it is also simple enough and doesn't cause any extra ifdef additions. Signed-off-by: Marcel Holtmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 211d31a4cc88..bf92cc85c086 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -626,6 +626,8 @@ generate_faults(VuDev *dev) { VuDevRegion *dev_region =3D &dev->regions[i]; int ret; #ifdef UFFDIO_REGISTER + struct uffdio_register reg_struct; + /* * We should already have an open ufd. Mark each memory * range as ufd. @@ -659,7 +661,7 @@ generate_faults(VuDev *dev) { "%s: Failed to madvise(NOHUGEPAGE) region %d: %s\n", __func__, i, strerror(errno)); } - struct uffdio_register reg_struct; + reg_struct.range.start =3D (uintptr_t)dev_region->mmap_addr; reg_struct.range.len =3D dev_region->size + dev_region->mmap_offse= t; reg_struct.mode =3D UFFDIO_REGISTER_MODE_MISSING; --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741560695150.02260631501417; Thu, 22 Dec 2022 12:39:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJR-0004sv-44; Thu, 22 Dec 2022 15:37:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJO-0004r8-DJ for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJM-0002LF-Me for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 0570CCED29; Thu, 22 Dec 2022 21:36:58 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 06/12] libvhost-user: Change dev->postcopy_ufd assignment to make it C90 compliant Date: Thu, 22 Dec 2022 21:36:45 +0100 Message-Id: <74db52afb1203c4580ffc7fa462b4b2ba260a353.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741561390100001 The assignment of dev->postcopy_ufd can be moved into an else clause and then the code becomes C90 compliant. CC libvhost-user.o libvhost-user.c: In function =E2=80=98vu_set_postcopy_advise=E2=80=99: libvhost-user.c:1625:5: error: ISO C90 forbids mixed declarations and code = [-Werror=3Ddeclaration-after-statement] 1625 | struct uffdio_api api_struct; | ^~~~~~ Understandable, it might be desired to avoid else clauses, but in this case it seems clear enough and frankly the dev->postcopy_ufd is only assigned once. Signed-off-by: Marcel Holtmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index bf92cc85c086..b28b66cdb159 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -1599,12 +1599,13 @@ vu_set_config(VuDev *dev, VhostUserMsg *vmsg) static bool vu_set_postcopy_advise(VuDev *dev, VhostUserMsg *vmsg) { - dev->postcopy_ufd =3D -1; #ifdef UFFDIO_API struct uffdio_api api_struct; =20 dev->postcopy_ufd =3D syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK= ); vmsg->size =3D 0; +#else + dev->postcopy_ufd =3D -1; #endif =20 if (dev->postcopy_ufd =3D=3D -1) { --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741754940818.0831268170823; Thu, 22 Dec 2022 12:42:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJP-0004sX-SH; Thu, 22 Dec 2022 15:37:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJO-0004rD-HJ for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJM-0002LL-QB for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 4BE8BCED2A; Thu, 22 Dec 2022 21:36:58 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 07/12] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU Date: Thu, 22 Dec 2022 21:36:46 +0100 Message-Id: <407f3665f0605df936e5bfe60831d180edfb8cca.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741757207100001 When the libvduse sources are used by another project, it can not be guaranteed that _GNU_SOURCE is set by the build system. If it is for example not set, errors like this show up. CC libvduse.o libvduse.c: In function =E2=80=98vduse_log_get=E2=80=99: libvduse.c:172:9: error: implicit declaration of function =E2=80=98ftruncat= e=E2=80=99; did you mean =E2=80=98strncat=E2=80=99? [-Werror=3Dimplicit-fun= ction-declaration] 172 | if (ftruncate(fd, size) =3D=3D -1) { | ^~~~~~~~~ | strncat The simplest way to allow external complication of libvduse.[ch] by setting _GNU_SOURCE if it is not already set by the build system. Signed-off-by: Marcel Holtmann Reviewed-by: Michael S. Tsirkin --- subprojects/libvduse/libvduse.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvdus= e.c index e089d4d546cf..c871bd331a6b 100644 --- a/subprojects/libvduse/libvduse.c +++ b/subprojects/libvduse/libvduse.c @@ -16,6 +16,10 @@ * later. See the COPYING file in the top-level directory. */ =20 +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include #include #include --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741546822536.866655872786; Thu, 22 Dec 2022 12:39:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJR-0004t6-LG; Thu, 22 Dec 2022 15:37:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJO-0004rG-Iu for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJM-0002LK-QK for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 8963BCED2B; Thu, 22 Dec 2022 21:36:58 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 08/12] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq Date: Thu, 22 Dec 2022 21:36:47 +0100 Message-Id: <9fe3fd8b042e048bd04d506ca6e43d738b5c45b7.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741547359100001 It seems there is no need to keep the inuse field signed and end up with compiler warnings for sign-compare. CC libvduse.o libvduse.c: In function =E2=80=98vduse_queue_pop=E2=80=99: libvduse.c:789:19: error: comparison of integer expressions of different si= gnedness: =E2=80=98int=E2=80=99 and =E2=80=98unsigned int=E2=80=99 [-Werror= =3Dsign-compare] 789 | if (vq->inuse >=3D vq->vring.num) { | ^~ Instead of casting the comparison to unsigned int, just make the inuse field unsigned int in the fist place. Signed-off-by: Marcel Holtmann Reviewed-by: Xie Yongji Reviewed-by: Michael S. Tsirkin --- subprojects/libvduse/libvduse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvdus= e.c index c871bd331a6b..338ad5e352e7 100644 --- a/subprojects/libvduse/libvduse.c +++ b/subprojects/libvduse/libvduse.c @@ -101,7 +101,7 @@ struct VduseVirtq { uint16_t signalled_used; bool signalled_used_valid; int index; - int inuse; + unsigned int inuse; bool ready; int fd; VduseDev *dev; --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741556330982.633523660499; Thu, 22 Dec 2022 12:39:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJa-0004v2-N7; Thu, 22 Dec 2022 15:37:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJZ-0004uk-AJ for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:17 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJX-0002Lm-Sz for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:17 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id D1933CED2C; Thu, 22 Dec 2022 21:36:58 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 09/12] libvduse: Fix assignment in vring_set_avail_event Date: Thu, 22 Dec 2022 21:36:48 +0100 Message-Id: <4a0fe2a6436464473119fdbf0bc4076b36fbb37f.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741557392100002 Since the assignment is causing a compiler warning, fix it by using memcpy instead. CC libvduse.o libvduse.c: In function =E2=80=98vring_set_avail_event=E2=80=99: libvduse.c:603:7: error: dereferencing type-punned pointer will break stric= t-aliasing rules [-Werror=3Dstrict-aliasin] 603 | *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) =3D htole16= (val); | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Marcel Holtmann Suggested-by: Xie Yongji Suggested-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin --- subprojects/libvduse/libvduse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvdus= e.c index 338ad5e352e7..377959a0b4fb 100644 --- a/subprojects/libvduse/libvduse.c +++ b/subprojects/libvduse/libvduse.c @@ -582,7 +582,8 @@ void vduse_queue_notify(VduseVirtq *vq) =20 static inline void vring_set_avail_event(VduseVirtq *vq, uint16_t val) { - *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) =3D htole16(val); + uint16_t val_le =3D htole16(val); + memcpy(&vq->vring.used->ring[vq->vring.num], &val_le, sizeof(uint16_t)= ); } =20 static bool vduse_queue_map_single_desc(VduseVirtq *vq, unsigned int *p_nu= m_sg, --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741442711157.86079366371678; Thu, 22 Dec 2022 12:37:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJR-0004t2-HH; Thu, 22 Dec 2022 15:37:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJP-0004rv-7G for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:07 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJN-0002Ln-Rk for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:06 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 39BF9CED28; Thu, 22 Dec 2022 21:36:59 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 10/12] libvhost-user: Fix assignment in vring_set_avail_event Date: Thu, 22 Dec 2022 21:36:49 +0100 Message-Id: <502b22723264db064e4b05008233a9c1f2f8aaaa.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741446085100002 Content-Type: text/plain; charset="utf-8" Since it was proposed to change the code in libvduse.c to use memcpy instead of an assignment, the code in libvhost-user.c should also be changed to use memcpy. Signed-off-by: Marcel Holtmann Suggested-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index b28b66cdb159..fc69783d2bf6 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -2478,14 +2478,13 @@ vring_used_flags_unset_bit(VuVirtq *vq, int mask) static inline void vring_set_avail_event(VuVirtq *vq, uint16_t val) { - uint16_t *avail; + uint16_t val_le =3D htole16(val); =20 if (!vq->notification) { return; } =20 - avail =3D (uint16_t *)&vq->vring.used->ring[vq->vring.num]; - *avail =3D htole16(val); + memcpy(&vq->vring.used->ring[vq->vring.num], &val_le, sizeof(uint16_t)= ); } =20 void --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741504182451.3805170859406; Thu, 22 Dec 2022 12:38:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJc-0004vp-DZ; Thu, 22 Dec 2022 15:37:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJa-0004v1-Ig for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:18 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJX-0002Lr-Vl for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:18 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 9AB04CED2D; Thu, 22 Dec 2022 21:36:59 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 11/12] libvhost-user: Add extra compiler warnings Date: Thu, 22 Dec 2022 21:36:50 +0100 Message-Id: <737ebf2e697f8640558e6f73d96a692711f548f6.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741505147100001 Content-Type: text/plain; charset="utf-8" In case libvhost-user is used externally, that projects compiler warnings might be more strict. Enforce an extra set of compiler warnings to catch issues early on. Signed-off-by: Marcel Holtmann Suggested-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin --- subprojects/libvhost-user/meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/meson.build b/subprojects/libvhost-u= ser/meson.build index 39825d9404ae..a18014e7f26f 100644 --- a/subprojects/libvhost-user/meson.build +++ b/subprojects/libvhost-user/meson.build @@ -1,6 +1,12 @@ project('libvhost-user', 'c', license: 'GPL-2.0-or-later', - default_options: ['c_std=3Dgnu99']) + default_options: ['warning_level=3D1', 'c_std=3Dgnu99']) + +cc =3D meson.get_compiler('c') +add_project_arguments(cc.get_supported_arguments('-Wsign-compare', + '-Wdeclaration-after-stat= ement', + '-Wstrict-aliasing'), + native: false, language: 'c') =20 threads =3D dependency('threads') glib =3D dependency('glib-2.0') --=20 2.38.1 From nobody Mon May 20 14:56:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671741548041697.3906602061802; Thu, 22 Dec 2022 12:39:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJa-0004v0-8n; Thu, 22 Dec 2022 15:37:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8SJZ-0004ul-Cq for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:17 -0500 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8SJX-0002Ls-Uo for qemu-devel@nongnu.org; Thu, 22 Dec 2022 15:37:17 -0500 Received: from fedora.. (p4fefcc21.dip0.t-ipconnect.de [79.239.204.33]) by mail.holtmann.org (Postfix) with ESMTPSA id 0A58ACED2E; Thu, 22 Dec 2022 21:37:00 +0100 (CET) From: Marcel Holtmann To: qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com, pbonzini@redhat.com Cc: marcel@holtmann.org Subject: [PATCH v4 12/12] libvduse: Add extra compiler warnings Date: Thu, 22 Dec 2022 21:36:51 +0100 Message-Id: <08daa1896ad8824e17d57d6a970bc0b4bee73ece.1671741278.git.marcel@holtmann.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.132.17; envelope-from=marcel@holtmann.org; helo=mail.holtmann.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671741549365100005 Content-Type: text/plain; charset="utf-8" In case libvhost-user is used externally, that projects compiler warnings might be more strict. Enforce an extra set of compiler warnings to catch issues early on. Signed-off-by: Marcel Holtmann Suggested-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin --- subprojects/libvduse/meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subprojects/libvduse/meson.build b/subprojects/libvduse/meson.= build index ba08f5ee1a03..3e3b53da33ae 100644 --- a/subprojects/libvduse/meson.build +++ b/subprojects/libvduse/meson.build @@ -1,6 +1,12 @@ project('libvduse', 'c', license: 'GPL-2.0-or-later', - default_options: ['c_std=3Dgnu99']) + default_options: ['warning_level=3D1', 'c_std=3Dgnu99']) + +cc =3D meson.get_compiler('c') +add_project_arguments(cc.get_supported_arguments('-Wsign-compare', + '-Wdeclaration-after-stat= ement', + '-Wstrict-aliasing'), + native: false, language: 'c') =20 libvduse =3D static_library('vduse', files('libvduse.c'), --=20 2.38.1