From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1T0VTI-0000os-GP for mharc-qemu-trivial@gnu.org; Sun, 12 Aug 2012 06:32:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0VTG-0000jh-Cs for qemu-trivial@nongnu.org; Sun, 12 Aug 2012 06:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0VTE-000767-7r for qemu-trivial@nongnu.org; Sun, 12 Aug 2012 06:32:34 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:54821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0VTA-00073J-FT; Sun, 12 Aug 2012 06:32:28 -0400 Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id F12FAA0B18; Sun, 12 Aug 2012 14:32:25 +0400 (MSK) Message-ID: <50278638.4070206@msgid.tls.msk.ru> Date: Sun, 12 Aug 2012 14:32:24 +0400 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:10.0.5) Gecko/20120624 Icedove/10.0.5 MIME-Version: 1.0 To: Peter Maydell References: <1344720275-26744-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1344720275-26744-1-git-send-email-peter.maydell@linaro.org> X-Enigmail-Version: 1.4.1 OpenPGP: id=804465C5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Kevin Wolf , qemu-devel@nongnu.org, patches@linaro.org Subject: Re: [Qemu-trivial] [PATCH] iov_send_recv(): Handle zero bytes case even if OS does not X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2012 10:32:35 -0000 On 12.08.2012 01:24, Peter Maydell wrote: > POSIX allows sendmsg() and recvmsg() to fail EMSGSIZE if passed a zero > msg.msg_iovlen (in particular the MacOS X implementation will do this). > Handle the case where iov_send_recv() is passed a zero byte count > explicitly, to avoid accidentally depending on the OS to treat zero > msg_iovlen as a no-op. > > Signed-off-by: Peter Maydell > --- > This is what was causing 'make check' to fail on MacOS X. > The other option was to declare that a zero bytecount was illegal, I guess. Acked-by: Michael Tokarev Kevin, does this fix the test-iov failure you're seeing on one of the build bots? Thank you! /mjt > iov.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/iov.c b/iov.c > index b333061..60705c7 100644 > --- a/iov.c > +++ b/iov.c > @@ -146,6 +146,13 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, > { > ssize_t ret; > unsigned si, ei; /* start and end indexes */ > + if (bytes == 0) { > + /* Catch the do-nothing case early, as otherwise we will pass an > + * empty iovec to sendmsg/recvmsg(), and not all implementations > + * accept this. > + */ > + return 0; > + } > > /* Find the start position, skipping `offset' bytes: > * first, skip all full-sized vector elements, */ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0VTD-0000fw-2S for qemu-devel@nongnu.org; Sun, 12 Aug 2012 06:32:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0VTA-00074H-N1 for qemu-devel@nongnu.org; Sun, 12 Aug 2012 06:32:31 -0400 Message-ID: <50278638.4070206@msgid.tls.msk.ru> Date: Sun, 12 Aug 2012 14:32:24 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1344720275-26744-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1344720275-26744-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] iov_send_recv(): Handle zero bytes case even if OS does not List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-trivial@nongnu.org, Kevin Wolf , qemu-devel@nongnu.org, patches@linaro.org On 12.08.2012 01:24, Peter Maydell wrote: > POSIX allows sendmsg() and recvmsg() to fail EMSGSIZE if passed a zero > msg.msg_iovlen (in particular the MacOS X implementation will do this). > Handle the case where iov_send_recv() is passed a zero byte count > explicitly, to avoid accidentally depending on the OS to treat zero > msg_iovlen as a no-op. > > Signed-off-by: Peter Maydell > --- > This is what was causing 'make check' to fail on MacOS X. > The other option was to declare that a zero bytecount was illegal, I guess. Acked-by: Michael Tokarev Kevin, does this fix the test-iov failure you're seeing on one of the build bots? Thank you! /mjt > iov.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/iov.c b/iov.c > index b333061..60705c7 100644 > --- a/iov.c > +++ b/iov.c > @@ -146,6 +146,13 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, > { > ssize_t ret; > unsigned si, ei; /* start and end indexes */ > + if (bytes == 0) { > + /* Catch the do-nothing case early, as otherwise we will pass an > + * empty iovec to sendmsg/recvmsg(), and not all implementations > + * accept this. > + */ > + return 0; > + } > > /* Find the start position, skipping `offset' bytes: > * first, skip all full-sized vector elements, */