qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] w32: Fix qemu_ftruncate64


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] w32: Fix qemu_ftruncate64
Date: Mon, 22 Aug 2011 11:32:41 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

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<address@hidden>

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 */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]