[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH v3] qemu-io: Add generic function f
Re: [Qemu-block] [Qemu-devel] [PATCH v3] qemu-io: Add generic function for reinitializing optind.
Wed, 9 Jan 2019 08:53:27 -0600
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1
On 1/9/19 7:44 AM, Daniel P. Berrangé wrote:
> On Wed, Jan 09, 2019 at 01:23:01PM +0000, Richard W.M. Jones wrote:
>> How about this one? Add a generic osdep function for reinitializing
>> optind, which does optreset on FreeBSD (but is identical on all other
>> OSes). Use it from qemu-io and qemu-img.
>> I have tested this on Linux, FreeBSD and OpenBSD.
>> WARNING: architecture specific defines should be avoided
>> #78: FILE: include/qemu/osdep.h:600:
>> +#ifdef __FreeBSD__
> Normally we'd suggest doing a configure test to for the platform
> feature and then using a feature based ifdef test. In this case
> though that would be difficult and/or overly complex.
> This does make me wonder about the other *BSDs, OS-X and Mingw
> though ? Should they all be using the #else codepath, or should
> the other BSDs / OS-X use the __FreeBSD__ codepath.
Indeed, and I already suggested a configure-time probe on the v2
review. My preference, if we want to go with this helper function for a
hard reset, would be:
optind = 1;
optreset = 1;
optind = 0;
where HAVE_OPTRESET is based on a configure-time probe.
Basically, any platform that HAS optreset will probably honor it; any
platform that lacks optreset is hopefully okay with the
POSIX-unspecified behavior of optind = 0.
But I do like the idea presented in this version of trying to isolate
the reset into a common helper function, so that if we have to make
later changes, we only have to touch the one function rather than all
callsites that reset getopt parsing.
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
Description: OpenPGP digital signature