From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh4C-00009p-F0 for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xqh45-0007FO-7p for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh45-0007FK-10 for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:21 -0500 From: Kevin Wolf Date: Tue, 18 Nov 2014 12:35:06 +0100 Message-Id: <1416310508-5122-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1416310508-5122-1-git-send-email-kwolf@redhat.com> References: <1416310508-5122-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 4/6] block/raw-posix: Fix preallocating write() loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, mreitz@redhat.com From: Max Reitz write() may write less bytes than requested; in this case, the number of bytes written is returned. This is the byte count we should be subtracting from the number of bytes still to be written, and not the byte count we requested to write. Reported-by: L=C3=A1szl=C3=B3 =C3=89rsek Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/raw-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 414e6d1..e0e48c5 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1451,7 +1451,7 @@ static int raw_create(const char *filename, QemuOpt= s *opts, Error **errp) "Could not write to the new file"); break; } - left -=3D num; + left -=3D result; } fsync(fd); g_free(buf); --=20 1.8.3.1