[{"id":1761641,"web_url":"http://patchwork.ozlabs.org/comment/1761641/","msgid":"<20170901122021.GN31680@redhat.com>","list_archive_url":null,"date":"2017-09-01T12:20:21","subject":"Re: [Qemu-devel] [PATCH v4 1/2] tests: Use real size for iov tests","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Fri, Sep 01, 2017 at 01:54:59PM +0200, Juan Quintela wrote:\n> We were using -1 instead of the real size because the functions check\n> what is bigger, size in bytes or the size of the iov.  Recent gcc's\n> barf at this.\n> \n> Signed-off-by: Juan Quintela <quintela@redhat.com>\n> Reviewed-by: Peter Xu <peterx@redhat.com>\n> Tested-by: Cleber Rosa <crosa@redhat.com>\n> --\n> \n> Remove comments about this feature.\n> Fix missing -1.\n> ---\n>  include/qemu/iov.h |  6 ------\n>  tests/test-iov.c   | 10 +++++-----\n>  2 files changed, 5 insertions(+), 11 deletions(-)\n> \n> diff --git a/include/qemu/iov.h b/include/qemu/iov.h\n> index bd9fd55b0a..72d4c559b4 100644\n> --- a/include/qemu/iov.h\n> +++ b/include/qemu/iov.h\n> @@ -31,11 +31,6 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt);\n>   * Number of bytes actually copied will be returned, which is\n>   *  min(bytes, iov_size(iov)-offset)\n>   * `Offset' must point to the inside of iovec.\n> - * It is okay to use very large value for `bytes' since we're\n> - * limited by the size of the iovec anyway, provided that the\n> - * buffer pointed to by buf has enough space.  One possible\n> - * such \"large\" value is -1 (sinice size_t is unsigned),\n> - * so specifying `-1' as `bytes' means 'up to the end of iovec'.\n>   */\n>  size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt,\n>                           size_t offset, const void *buf, size_t bytes);\n> @@ -76,7 +71,6 @@ iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt,\n>   * up to the end of it, will be filled with the specified value.\n>   * Function return actual number of bytes processed, which is\n>   * min(size, iov_size(iov) - offset).\n> - * Again, it is okay to use large value for `bytes' to mean \"up to the end\".\n>   */\n>  size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,\n>                    size_t offset, int fillc, size_t bytes);\n\nI'm not sure its right to be removing these comments, unless you've\naudited the code to ensure no caller outside the test suite is\nrelying on this documented behaviour.\n\n> diff --git a/tests/test-iov.c b/tests/test-iov.c\n> index fa3d75aee1..458ca25099 100644\n> --- a/tests/test-iov.c\n> +++ b/tests/test-iov.c\n> @@ -81,17 +81,17 @@ static void test_to_from_buf_1(void)\n>            * skip whole vector and process exactly 0 bytes */\n>  \n>           /* first set bytes [i..sz) to some \"random\" value */\n> -         n = iov_memset(iov, niov, 0, 0xff, -1);\n> +         n = iov_memset(iov, niov, 0, 0xff, sz);\n>           g_assert(n == sz);\n>  \n>           /* next copy bytes [i..sz) from ibuf to iovec */\n> -         n = iov_from_buf(iov, niov, i, ibuf + i, -1);\n> +         n = iov_from_buf(iov, niov, i, ibuf + i, sz - i);\n>           g_assert(n == sz - i);\n>  \n>           /* clear part of obuf */\n>           memset(obuf + i, 0, sz - i);\n>           /* and set this part of obuf to values from iovec */\n> -         n = iov_to_buf(iov, niov, i, obuf + i, -1);\n> +         n = iov_to_buf(iov, niov, i, obuf + i, sz - i);\n>           g_assert(n == sz - i);\n>  \n>           /* now compare resulting buffers */\n> @@ -109,7 +109,7 @@ static void test_to_from_buf_1(void)\n>                * with j in [i..sz]. */\n>  \n>               /* clear iovec */\n> -             n = iov_memset(iov, niov, 0, 0xff, -1);\n> +             n = iov_memset(iov, niov, 0, 0xff, sz);\n>               g_assert(n == sz);\n>  \n>               /* copy bytes [i..j) from ibuf to iovec */\n> @@ -225,7 +225,7 @@ static void test_io(void)\n>         for (i = 0; i <= sz; ++i) {\n>             for (j = i; j <= sz; ++j) {\n>                 k = i;\n> -               iov_memset(iov, niov, 0, 0xff, -1);\n> +               iov_memset(iov, niov, 0, 0xff, sz);\n>                 do {\n>                     s = g_test_rand_int_range(0, j - k + 1);\n>                     r = iov_recv(sv[0], iov, niov, k, s);\n\nFor the test-iov.c changes though you can have\n\nReviewed-by: Daniel P. Berrange <berrange@redhat.com>\n\n\nRegards,\nDaniel","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkJHh3Db7z9sRV\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 22:21:03 +1000 (AEST)","from localhost ([::1]:38579 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnkwW-00025p-V0\n\tfor incoming@patchwork.ozlabs.org; Fri, 01 Sep 2017 08:21:00 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:46285)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1dnkw5-00023b-DD\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 08:20:34 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1dnkw1-0001ll-50\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 08:20:33 -0400","from mx1.redhat.com ([209.132.183.28]:53038)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1dnkw0-0001lb-SJ\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 08:20:29 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id EE40C25C25\n\tfor <qemu-devel@nongnu.org>; Fri,  1 Sep 2017 12:20:27 +0000 (UTC)","from redhat.com (unknown [10.42.22.189])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id AE52EA2A6F;\n\tFri,  1 Sep 2017 12:20:24 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com EE40C25C25","Date":"Fri, 1 Sep 2017 13:20:21 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Juan Quintela <quintela@redhat.com>","Message-ID":"<20170901122021.GN31680@redhat.com>","References":"<20170901115500.12654-1-quintela@redhat.com>\n\t<20170901115500.12654-2-quintela@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20170901115500.12654-2-quintela@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tFri, 01 Sep 2017 12:20:28 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v4 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":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"lvivier@redhat.com, qemu-devel@nongnu.org, peterx@redhat.com,\n\tdgilbert@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1761759,"web_url":"http://patchwork.ozlabs.org/comment/1761759/","msgid":"<87wp5i78kl.fsf@secure.laptop>","list_archive_url":null,"date":"2017-09-01T15:16:42","subject":"Re: [Qemu-devel] [PATCH v4 1/2] tests: Use real size for iov tests","submitter":{"id":2643,"url":"http://patchwork.ozlabs.org/api/people/2643/","name":"Juan Quintela","email":"quintela@redhat.com"},"content":"\"Daniel P. Berrange\" <berrange@redhat.com> wrote:\n> On Fri, Sep 01, 2017 at 01:54:59PM +0200, Juan Quintela wrote:\n>> We were using -1 instead of the real size because the functions check\n>> what is bigger, size in bytes or the size of the iov.  Recent gcc's\n>> barf at this.\n>> \n>> Signed-off-by: Juan Quintela <quintela@redhat.com>\n>> Reviewed-by: Peter Xu <peterx@redhat.com>\n>> Tested-by: Cleber Rosa <crosa@redhat.com>\n>> --\n>> \n>> Remove comments about this feature.\n>> Fix missing -1.\n>> ---\n>>  include/qemu/iov.h |  6 ------\n>>  tests/test-iov.c   | 10 +++++-----\n>>  2 files changed, 5 insertions(+), 11 deletions(-)\n>> \n>> diff --git a/include/qemu/iov.h b/include/qemu/iov.h\n>> index bd9fd55b0a..72d4c559b4 100644\n>> --- a/include/qemu/iov.h\n>> +++ b/include/qemu/iov.h\n>> @@ -31,11 +31,6 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt);\n>>   * Number of bytes actually copied will be returned, which is\n>>   *  min(bytes, iov_size(iov)-offset)\n>>   * `Offset' must point to the inside of iovec.\n>> - * It is okay to use very large value for `bytes' since we're\n>> - * limited by the size of the iovec anyway, provided that the\n>> - * buffer pointed to by buf has enough space.  One possible\n>> - * such \"large\" value is -1 (sinice size_t is unsigned),\n>> - * so specifying `-1' as `bytes' means 'up to the end of iovec'.\n>>   */\n>>  size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt,\n>>                           size_t offset, const void *buf, size_t bytes);\n>> @@ -76,7 +71,6 @@ iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt,\n>>   * up to the end of it, will be filled with the specified value.\n>>   * Function return actual number of bytes processed, which is\n>>   * min(size, iov_size(iov) - offset).\n>> - * Again, it is okay to use large value for `bytes' to mean \"up to the end\".\n>>   */\n>>  size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,\n>>                    size_t offset, int fillc, size_t bytes);\n>\n> I'm not sure its right to be removing these comments, unless you've\n> audited the code to ensure no caller outside the test suite is\n> relying on this documented behaviour.\n\nI did.  The caller call with the real size of the buffer.\niov_memset() still works with the -1 size.\n\niov_to/from_buf, the non full versions don't work, because the inline\ngets confused with -1 with newer gcc's.\n>\n> For the test-iov.c changes though you can have\n>\n> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>\n\nLater, Juan.","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=quintela@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkNJW0lrnz9t1t\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 01:22:03 +1000 (AEST)","from localhost ([::1]:45340 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnnlh-0000Ub-4P\n\tfor incoming@patchwork.ozlabs.org; Fri, 01 Sep 2017 11:22:01 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:45046)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <quintela@redhat.com>) id 1dnngd-0004A9-Hr\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 11:16:52 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <quintela@redhat.com>) id 1dnngc-0000G4-Fw\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 11:16:47 -0400","from mx1.redhat.com ([209.132.183.28]:58110)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <quintela@redhat.com>) id 1dnngc-0000Fe-7u\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 11:16:46 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 586BF61484\n\tfor <qemu-devel@nongnu.org>; Fri,  1 Sep 2017 15:16:45 +0000 (UTC)","from localhost (ovpn-117-184.ams2.redhat.com [10.36.117.184])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id C743AA63B2;\n\tFri,  1 Sep 2017 15:16:44 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 586BF61484","From":"Juan Quintela <quintela@redhat.com>","To":"\"Daniel P. Berrange\" <berrange@redhat.com>","In-Reply-To":"<20170901122021.GN31680@redhat.com> (Daniel P. Berrange's\n\tmessage of \"Fri, 1 Sep 2017 13:20:21 +0100\")","References":"<20170901115500.12654-1-quintela@redhat.com>\n\t<20170901115500.12654-2-quintela@redhat.com>\n\t<20170901122021.GN31680@redhat.com>","User-Agent":"Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)","Date":"Fri, 01 Sep 2017 17:16:42 +0200","Message-ID":"<87wp5i78kl.fsf@secure.laptop>","MIME-Version":"1.0","Content-Type":"text/plain","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tFri, 01 Sep 2017 15:16:45 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v4 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":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Reply-To":"quintela@redhat.com","Cc":"lvivier@redhat.com, qemu-devel@nongnu.org, peterx@redhat.com,\n\tdgilbert@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]