All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Fabien Chouteau <chouteau@adacore.com>
Cc: blauwirbel@gmail.com, weil@mail.berlios.de, pbonzini@redhat.com,
	qemu-devel@nongnu.org, jan.kiszka@siemens.com
Subject: Re: [Qemu-devel] [PATCH 1.0] Replace WriteFileEx with WriteFile in qemu_create_pidfile
Date: Wed, 09 Nov 2011 13:44:14 -0600	[thread overview]
Message-ID: <4EBAD80E.7000907@us.ibm.com> (raw)
In-Reply-To: <1320676574-19251-1-git-send-email-chouteau@adacore.com>

On 11/07/2011 08:36 AM, Fabien Chouteau wrote:
> The function that writes pidfile for win32 uses WriteFileEx which is an
> asynchronous IO function. The arguments given to WriteFileEx are allocated on
> the stack and one of them is "in out". When the IO operation is actually
> executed the calling function has already returned, so the arguments are no
> longer allocated or allocated to another frame.
>
> Signed-off-by: Fabien Chouteau<chouteau@adacore.com>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   os-win32.c |    7 ++++---
>   1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/os-win32.c b/os-win32.c
> index 7909401..8ad5fa1 100644
> --- a/os-win32.c
> +++ b/os-win32.c
> @@ -130,14 +130,15 @@ int qemu_create_pidfile(const char *filename)
>       memset(&overlap, 0, sizeof(overlap));
>
>       file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
> -		      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
> +                      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
>
>       if (file == INVALID_HANDLE_VALUE) {
>           return -1;
>       }
>       len = snprintf(buffer, sizeof(buffer), "%d\n", getpid());
> -    ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
> -		&overlap, NULL);
> +    ret = WriteFile(file, (LPCVOID)buffer, (DWORD)len,
> +                    NULL,&overlap);
> +    CloseHandle(file);
>       if (ret == 0) {
>           return -1;
>       }

      parent reply	other threads:[~2011-11-09 19:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 14:36 [Qemu-devel] [PATCH 1.0] Replace WriteFileEx with WriteFile in qemu_create_pidfile Fabien Chouteau
2011-11-07 14:42 ` Paolo Bonzini
2011-11-09 19:44 ` Anthony Liguori [this message]

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=4EBAD80E.7000907@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=chouteau@adacore.com \
    --cc=jan.kiszka@siemens.com \
    --cc=pbonzini@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.