On 03.01.19 10:47, Richard W.M. Jones wrote: > On FreeBSD 11.2: > > $ nbdkit memory size=1M --run './qemu-io -f raw -c "aio_write 0 512" $nbd' > Parsing error: non-numeric argument, or extraneous/unrecognized suffix -- > aio_write > > After main option parsing, we reinitialize optind so we can parse each > command. However reinitializing optind to 0 does not work on FreeBSD. > What happens when you do this is optind remains 0 after the option > parsing loop, and the result is we try to parse argv[optind] == > argv[0] == "aio_write" as if it was the first parameter. > > The FreeBSD manual page says: > > In order to use getopt() to evaluate multiple sets of arguments, or to > evaluate a single set of arguments multiple times, the variable optreset > must be set to 1 before the second and each additional set of calls to > getopt(), and the variable optind must be reinitialized.
[...] > Note I didn't set optreset. It's not present in glibc and the "hard > reset" is not necessary in this context. But it sure sounds like FreeBSD requires you to set it, doesn't it? Max > Signed-off-by: Richard W.M. Jones <rjo...@redhat.com> > --- > qemu-io-cmds.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c > index 2c39124036..aa10ed5a20 100644 > --- a/qemu-io-cmds.c > +++ b/qemu-io-cmds.c > @@ -114,7 +114,7 @@ static int command(BlockBackend *blk, const cmdinfo_t > *ct, int argc, > } > } > > - optind = 0; > + optind = 1; > return ct->cfunc(blk, argc, argv); > } > >
signature.asc
Description: OpenPGP digital signature