From: Paolo Bonzini <pbonzini@redhat.com>
To: riegamaths@gmail.com
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-trivial] [PATCH] block: Don't forget to delete temporary file
Date: Wed, 05 Sep 2012 17:40:25 +0200 [thread overview]
Message-ID: <50477269.8050807@redhat.com> (raw)
In-Reply-To: <1346851582-9296-1-git-send-email-riegamaths@gmail.com>
Il 05/09/2012 15:26, riegamaths@gmail.com ha scritto:
> From: Dunrong Huang <riegamaths@gmail.com>
>
> The caller would not delete temporary file after failed get_tmp_filename().
>
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
> block.c | 6 +++++-
> 1 个文件被修改,插入 5 行(+),删除 1 行(-)
>
> diff --git a/block.c b/block.c
> index 074987e..2bc9f75 100644
> --- a/block.c
> +++ b/block.c
> @@ -433,7 +433,11 @@ int get_tmp_filename(char *filename, int size)
> return -EOVERFLOW;
> }
> fd = mkstemp(filename);
> - if (fd < 0 || close(fd)) {
> + if (fd < 0) {
> + return -errno;
> + }
> + if (close(fd) != 0) {
> + unlink(filename);
> return -errno;
> }
> return 0;
>
Not necessary, mkstemp will not create a file if it returns an error.
Paolo
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: riegamaths@gmail.com
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] block: Don't forget to delete temporary file
Date: Wed, 05 Sep 2012 17:40:25 +0200 [thread overview]
Message-ID: <50477269.8050807@redhat.com> (raw)
In-Reply-To: <1346851582-9296-1-git-send-email-riegamaths@gmail.com>
Il 05/09/2012 15:26, riegamaths@gmail.com ha scritto:
> From: Dunrong Huang <riegamaths@gmail.com>
>
> The caller would not delete temporary file after failed get_tmp_filename().
>
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
> block.c | 6 +++++-
> 1 个文件被修改,插入 5 行(+),删除 1 行(-)
>
> diff --git a/block.c b/block.c
> index 074987e..2bc9f75 100644
> --- a/block.c
> +++ b/block.c
> @@ -433,7 +433,11 @@ int get_tmp_filename(char *filename, int size)
> return -EOVERFLOW;
> }
> fd = mkstemp(filename);
> - if (fd < 0 || close(fd)) {
> + if (fd < 0) {
> + return -errno;
> + }
> + if (close(fd) != 0) {
> + unlink(filename);
> return -errno;
> }
> return 0;
>
Not necessary, mkstemp will not create a file if it returns an error.
Paolo
next prev parent reply other threads:[~2012-09-05 15:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 13:26 [Qemu-trivial] [PATCH] block: Don't forget to delete temporary file riegamaths
2012-09-05 13:26 ` [Qemu-devel] " riegamaths
2012-09-05 15:40 ` Paolo Bonzini [this message]
2012-09-05 15:40 ` Paolo Bonzini
2012-09-05 15:51 ` [Qemu-trivial] " Dunrong Huang
2012-09-05 15:51 ` [Qemu-devel] " Dunrong Huang
2012-09-05 16:02 ` [Qemu-trivial] " Markus Armbruster
2012-09-05 16:02 ` Markus Armbruster
2012-09-05 16:23 ` [Qemu-trivial] " Paolo Bonzini
2012-09-05 16:23 ` [Qemu-devel] " Paolo Bonzini
2012-09-05 16:28 ` [Qemu-trivial] " Eric Blake
2012-09-05 16:28 ` [Qemu-devel] " Eric Blake
2012-09-06 3:47 ` [Qemu-trivial] " Dunrong Huang
2012-09-06 3:47 ` [Qemu-devel] " Dunrong Huang
2012-09-11 10:23 ` [Qemu-trivial] " Kevin Wolf
2012-09-11 10:23 ` Kevin Wolf
2012-09-14 7:45 ` [Qemu-trivial] " Stefan Hajnoczi
2012-09-14 7:45 ` Stefan Hajnoczi
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=50477269.8050807@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=riegamaths@gmail.com \
/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.