From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefan Weil <weil@mail.berlios.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] w32: Fix qemu_ftruncate64
Date: Mon, 22 Aug 2011 11:32:41 -0500 [thread overview]
Message-ID: <4E5284A9.1030605@codemonkey.ws> (raw)
In-Reply-To: <1313835005-32480-1-git-send-email-weil@mail.berlios.de>
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<weil@mail.berlios.de>
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 */
next prev parent reply other threads:[~2011-08-22 16:32 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
2011-08-22 16:32 ` Anthony Liguori [this message]
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=4E5284A9.1030605@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/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).