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 <ebl...@redhat.com> > --- > 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