[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] qemu-io: Don't die on second open
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] qemu-io: Don't die on second open |
Date: |
Wed, 24 May 2017 14:28:33 +0800 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Thu, 05/18 21:32, Eric Blake wrote:
> Failure to open a file in qemu-io should normally return 1 on
> failure to end the command loop, on the presumption that when
> batching commands all on the command line, failure to open means
> nothing further can be attempted. But when executing qemu-io
> interactively, there is a special case: if open is executed a
> second time, we print a hint that the user should try the
> interactive 'close' first. But the hint is useless if we don't
> actually LET them try 'close'.
>
> This has been awkward since at least as far back as commit
> 43642b3, in 2011 (probably earlier, but git blame has a harder
> time going past the file renames at that point).
>
> Signed-off-by: Eric Blake <address@hidden>
> ---
> qemu-io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qemu-io.c b/qemu-io.c
> index 34fa8a1..0c82dac 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -63,7 +63,7 @@ static int openfile(char *name, int flags, bool
> writethrough, bool force_share,
> if (qemuio_blk) {
> error_report("file open already, try 'help close'");
> QDECREF(opts);
> - return 1;
> + return 0;
> }
>
> if (force_share) {
> --
> 2.9.4
>
>
Hmm, failure is failure, why is "return 0" better than "return 1"?
If the control flow in the caller has a problem, fix it there? Specifically, I
don't think failed interactive open need to exit program, at all.
Fam