qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <weil@mail.berlios.de>
To: Kevin Wolf <kwolf@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] w32: Fix qemu_ftruncate64
Date: Sat, 20 Aug 2011 14:01:31 +0200	[thread overview]
Message-ID: <4E4FA21B.9050208@mail.berlios.de> (raw)
In-Reply-To: <1313835005-32480-1-git-send-email-weil@mail.berlios.de>

Am 20.08.2011 12:10, schrieb Stefan Weil:
> 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<weil@mail.berlios.de>
> ---
>   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 */

This is a bug fix, please apply it to git master and stable-0.15.

Thanks,
Stefan W.

  reply	other threads:[~2011-08-20 12:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-14 16:32 [Qemu-devel] [Bug 826363] [NEW] qemu-img convert does not work with vdi files Steve Si
2011-08-14 21:25 ` [Qemu-devel] [Bug 826363] " Steve Si
2011-08-15 21:12 ` [Qemu-devel] [Bug 826363] [NEW] " Stefan Hajnoczi
2011-08-15 22:59 ` [Qemu-devel] [Bug 826363] " Steve Si
2011-08-16 13:10   ` Stefan Hajnoczi
2011-08-16 18:07 ` Steve Si
2011-08-17 16:29   ` Stefan Hajnoczi
2011-08-17 16:44     ` Stefan Hajnoczi
2011-08-20  8:50       ` Stefan Weil
2011-08-20  8:57         ` Michael Tokarev
2011-08-20 10:10         ` [Qemu-devel] [PATCH] w32: Fix qemu_ftruncate64 Stefan Weil
2011-08-20 12:01           ` Stefan Weil [this message]
2011-08-22 16:32           ` Anthony Liguori
2011-08-20 10:15         ` [Qemu-devel] [Bug 826363] Re: qemu-img convert does not work with vdi files Stefan Weil
2011-08-17 18:46 ` Steve Si
2011-08-17 19:05 ` Steve Si
2011-08-19  4:14   ` Stefan Hajnoczi
2011-08-19 19:06 ` Steve Si
2011-08-20 12:21 ` Stefan Weil
2011-08-20 17:13 ` Steve Si
2011-08-27 16:23 ` Steve Si
2011-08-27 19:42 ` Stefan Weil
2012-02-15  6:17 ` Stefan Weil
2013-02-03  9:28 ` Aaron Bouzek
2013-02-03  9:38 ` Aaron Bouzek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4FA21B.9050208@mail.berlios.de \
    --to=weil@mail.berlios.de \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).