qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v2] qemu-io: Reinitialize optind to 1 (not 0) be


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v2] qemu-io: Reinitialize optind to 1 (not 0) before parsing inner command.
Date: Wed, 9 Jan 2019 13:33:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 08.01.19 15:51, Eric Blake wrote:
> On 1/8/19 6:16 AM, Kevin Wolf wrote:
> 
> 
>> Unconditionally setting optind = 1 looks fine. I would, however, quote a
>> different part of the glibc man page (in addition or instead of the
>> paragraph you already quoted):
>>
>>     The  variable  optind is the index of the next element to be
>>     processed in argv.  The system initializes this value to 1.  The
>>     caller can reset it to 1 to restart scanning of the same argv, or
>>     when scanning a new argument vector.
>>
>> This makes it pretty clear that optind = 1 is fine for our case with
>> glibc. The FreeBSD man page still suggests that we need optreset = 1, so
>> I suppose we'd end up with something like:
>>
>> ...
>> optind = 1;
>> #ifdef __FreeBSD__
>> optreset = 1;
>> #endif
> 
> If you really want to set optreset for BSD systems, I'd do a configure
> probe for whether optreset exists, and if so set it for ALL platforms
> that have optreset, not just for __FreeBSD__.  (That, and checkpatch.pl
> will gripe if you don't do it that way).

...or you just make it a weak variable...

> But I'm leaning towards not bothering with optreset UNLESS someone
> proves they have a case where it actually matters.

I don't care in this case, but this is not a good argument.

As I said before, in general, if an interface description says to do X
for Y you cannot rely on doing Y without X just because it works right now.

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]