From nobody Tue Nov 4 08:28:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504266090402979.3490388899864; Fri, 1 Sep 2017 04:41:30 -0700 (PDT) Received: from localhost ([::1]:36471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnkKH-0001O7-Ax for importer@patchew.org; Fri, 01 Sep 2017 07:41:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnkDn-0003aN-S2 for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:34:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnkDl-0007gi-VI for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:34:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnkDl-0007gS-N8 for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:34:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C333F80C19 for ; Fri, 1 Sep 2017 11:34:44 +0000 (UTC) Received: from secure.mitica (ovpn-117-188.ams2.redhat.com [10.36.117.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E255953DB; Fri, 1 Sep 2017 11:34:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C333F80C19 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 1 Sep 2017 13:34:37 +0200 Message-Id: <20170901113438.12523-2-quintela@redhat.com> In-Reply-To: <20170901113438.12523-1-quintela@redhat.com> References: <20170901113438.12523-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 01 Sep 2017 11:34:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/2] tests: Use real size for iov tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We were using -1 instead of the real size because the functions check what is bigger, size in bytes or the size of the iov. Recent gcc's barf at this. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu Tested-by: Cleber Rosa -- Remove comments about this feature. Fix missing -1. --- include/qemu/iov.h | 6 ------ tests/test-iov.c | 10 +++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/qemu/iov.h b/include/qemu/iov.h index bd9fd55b0a..72d4c559b4 100644 --- a/include/qemu/iov.h +++ b/include/qemu/iov.h @@ -31,11 +31,6 @@ size_t iov_size(const struct iovec *iov, const unsigned = int iov_cnt); * Number of bytes actually copied will be returned, which is * min(bytes, iov_size(iov)-offset) * `Offset' must point to the inside of iovec. - * It is okay to use very large value for `bytes' since we're - * limited by the size of the iovec anyway, provided that the - * buffer pointed to by buf has enough space. One possible - * such "large" value is -1 (sinice size_t is unsigned), - * so specifying `-1' as `bytes' means 'up to the end of iovec'. */ size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt, size_t offset, const void *buf, size_t bytes); @@ -76,7 +71,6 @@ iov_to_buf(const struct iovec *iov, const unsigned int io= v_cnt, * up to the end of it, will be filled with the specified value. * Function return actual number of bytes processed, which is * min(size, iov_size(iov) - offset). - * Again, it is okay to use large value for `bytes' to mean "up to the end= ". */ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, size_t offset, int fillc, size_t bytes); diff --git a/tests/test-iov.c b/tests/test-iov.c index fa3d75aee1..458ca25099 100644 --- a/tests/test-iov.c +++ b/tests/test-iov.c @@ -81,17 +81,17 @@ static void test_to_from_buf_1(void) * skip whole vector and process exactly 0 bytes */ =20 /* first set bytes [i..sz) to some "random" value */ - n =3D iov_memset(iov, niov, 0, 0xff, -1); + n =3D iov_memset(iov, niov, 0, 0xff, sz); g_assert(n =3D=3D sz); =20 /* next copy bytes [i..sz) from ibuf to iovec */ - n =3D iov_from_buf(iov, niov, i, ibuf + i, -1); + n =3D iov_from_buf(iov, niov, i, ibuf + i, sz - i); g_assert(n =3D=3D sz - i); =20 /* clear part of obuf */ memset(obuf + i, 0, sz - i); /* and set this part of obuf to values from iovec */ - n =3D iov_to_buf(iov, niov, i, obuf + i, -1); + n =3D iov_to_buf(iov, niov, i, obuf + i, sz - i); g_assert(n =3D=3D sz - i); =20 /* now compare resulting buffers */ @@ -109,7 +109,7 @@ static void test_to_from_buf_1(void) * with j in [i..sz]. */ =20 /* clear iovec */ - n =3D iov_memset(iov, niov, 0, 0xff, -1); + n =3D iov_memset(iov, niov, 0, 0xff, sz); g_assert(n =3D=3D sz); =20 /* copy bytes [i..j) from ibuf to iovec */ @@ -225,7 +225,7 @@ static void test_io(void) for (i =3D 0; i <=3D sz; ++i) { for (j =3D i; j <=3D sz; ++j) { k =3D i; - iov_memset(iov, niov, 0, 0xff, -1); + iov_memset(iov, niov, 0, 0xff, sz); do { s =3D g_test_rand_int_range(0, j - k + 1); r =3D iov_recv(sv[0], iov, niov, k, s); --=20 2.13.5 From nobody Tue Nov 4 08:28:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504266437108770.650842435959; Fri, 1 Sep 2017 04:47:17 -0700 (PDT) Received: from localhost ([::1]:36695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnkPs-0006y1-1Q for importer@patchew.org; Fri, 01 Sep 2017 07:47:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnkDs-0003gR-4x for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnkDn-0007ha-Gz for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:34:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58862) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnkDn-0007gv-CL for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:34:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79E8CC056819 for ; Fri, 1 Sep 2017 11:34:46 +0000 (UTC) Received: from secure.mitica (ovpn-117-188.ams2.redhat.com [10.36.117.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20A7996146; Fri, 1 Sep 2017 11:34:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79E8CC056819 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 1 Sep 2017 13:34:38 +0200 Message-Id: <20170901113438.12523-3-quintela@redhat.com> In-Reply-To: <20170901113438.12523-1-quintela@redhat.com> References: <20170901113438.12523-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 01 Sep 2017 11:34:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/2] tests: Make vmgenid test compile X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Just make sure that nr_tables is size_t not int. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Juan Quintela Tested-by: Cleber Rosa -- Drop the s/g_new0/g_malloc0/ change. --- tests/vmgenid-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 3d5c1c3615..bcd3d7ec07 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(void) AcpiRsdpDescriptor rsdp_table; uint32_t rsdt; AcpiRsdtDescriptorRev1 rsdt_table; - int tables_nr; + size_t tables_nr; uint32_t *tables; AcpiTableHeader ssdt_table; VgidTable vgid_table; --=20 2.13.5