From: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
To: <dsterba@suse.cz>
Cc: <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 3/4] btrfs-progs: delete invalid output file when btrfs-image failed
Date: Tue, 24 Jun 2014 09:41:56 +0800 [thread overview]
Message-ID: <1403574116.3826.1.camel@localhost.localdomain> (raw)
In-Reply-To: <20140623141557.GG1553@twin.jikos.cz>
On Mon, 2014-06-23 at 16:15 +0200, David Sterba wrote:
> On Thu, Jun 19, 2014 at 09:46:02AM +0800, Gui Hecheng wrote:
> > When btrfs-image failed to create an image, the invalid output file
> > had better be deleted to prevent being used mistakenly in the future.
> >
> > Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
> > ---
> > btrfs-image.c | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/btrfs-image.c b/btrfs-image.c
> > index 549722c..b235b87 100644
> > --- a/btrfs-image.c
> > +++ b/btrfs-image.c
> > @@ -2598,8 +2598,16 @@ int main(int argc, char *argv[])
> > out:
> > if (out == stdout)
> > fflush(out);
> > - else
> > + else {
> > fclose(out);
> > + if (ret && create) {
> > + ret = unlink(target);
>
> The previous value is overwritten and in case of unlink() success it's
> returned as success of main(), which is not true. So a local variable
> has to be used instead.
>
Yes, I'll rework & resend it soon. Thanks.
> > + if (ret)
> > + fprintf(stderr,
> > + "unlink output file failed : %s\n",
> > + strerror(errno));
> > + }
> > + }
> >
> > return !!ret;
next prev parent reply other threads:[~2014-06-24 1:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 1:46 [PATCH 1/4] btrfs-progs: cleanup duplicate assignment of variable leaf for btrfs-image Gui Hecheng
2014-06-19 1:46 ` [PATCH 2/4] btrfs-progs: deal with invalid option combinations " Gui Hecheng
2014-06-23 14:12 ` David Sterba
2014-06-24 1:43 ` Gui Hecheng
2014-06-24 2:36 ` [PATCH v2 " Gui Hecheng
2014-06-24 2:51 ` Gui Hecheng
2014-06-24 3:16 ` [PATCH v3 " Gui Hecheng
2014-06-19 1:46 ` [PATCH 3/4] btrfs-progs: delete invalid output file when btrfs-image failed Gui Hecheng
2014-06-23 14:15 ` David Sterba
2014-06-24 1:41 ` Gui Hecheng [this message]
2014-06-24 2:38 ` [PATCH v2 " Gui Hecheng
2014-06-24 3:05 ` Gui Hecheng
2014-06-24 3:16 ` [PATCH v3 " Gui Hecheng
2014-06-24 8:47 ` David Sterba
2014-06-19 1:46 ` [PATCH 4/4] btrfs-progs: update manpage for btrfs-image with -m option added Gui Hecheng
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=1403574116.3826.1.camel@localhost.localdomain \
--to=guihc.fnst@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.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