From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:32799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvXQe-0001Z9-T5 for qemu-devel@nongnu.org; Mon, 22 Aug 2011 12:32:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QvXQa-0003HH-Gd for qemu-devel@nongnu.org; Mon, 22 Aug 2011 12:32:48 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:50390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvXQa-0003Gd-BL for qemu-devel@nongnu.org; Mon, 22 Aug 2011 12:32:44 -0400 Received: by ywf9 with SMTP id 9so4301504ywf.4 for ; Mon, 22 Aug 2011 09:32:43 -0700 (PDT) Message-ID: <4E5284A9.1030605@codemonkey.ws> Date: Mon, 22 Aug 2011 11:32:41 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <4E4F756C.3060907@mail.berlios.de> <1313835005-32480-1-git-send-email-weil@mail.berlios.de> In-Reply-To: <1313835005-32480-1-git-send-email-weil@mail.berlios.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] w32: Fix qemu_ftruncate64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-devel@nongnu.org On 08/20/2011 05:10 AM, Stefan Weil wrote: > SetFilePointer returns INVALID_SET_FILE_POINTER when it fails. > In addition, GetLastError must be checked. > > The first call of SetFilePointer did not use INVALID_SET_FILE_POINTER, > the second call used wrong error handling. > > Signed-off-by: Stefan Weil Applied. Thanks. Regards, Anthony Liguori > --- > block/raw-win32.c | 8 ++++++-- > 1 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/block/raw-win32.c b/block/raw-win32.c > index e47cfe0..b7dd357 100644 > --- a/block/raw-win32.c > +++ b/block/raw-win32.c > @@ -41,6 +41,7 @@ typedef struct BDRVRawState { > int qemu_ftruncate64(int fd, int64_t length) > { > LARGE_INTEGER li; > + DWORD dw; > LONG high; > HANDLE h; > BOOL res; > @@ -53,12 +54,15 @@ int qemu_ftruncate64(int fd, int64_t length) > /* get current position, ftruncate do not change position */ > li.HighPart = 0; > li.LowPart = SetFilePointer (h, 0,&li.HighPart, FILE_CURRENT); > - if (li.LowPart == 0xffffffffUL&& GetLastError() != NO_ERROR) > + if (li.LowPart == INVALID_SET_FILE_POINTER&& GetLastError() != NO_ERROR) { > return -1; > + } > > high = length>> 32; > - if (!SetFilePointer(h, (DWORD) length,&high, FILE_BEGIN)) > + dw = SetFilePointer(h, (DWORD) length,&high, FILE_BEGIN); > + if (dw == INVALID_SET_FILE_POINTER&& GetLastError() != NO_ERROR) { > return -1; > + } > res = SetEndOfFile(h); > > /* back to old position */