From: Christian Couder Date: Tue, 02 Aug 2011 06:41:41 GMT Subject: Re: [PATCH 09/18] revert: Don't create invalid replay_opts in parse_args Message-ID: <201108020841.41593.chriscool@tuxfamily.org> In-Reply-To: <201108020828.37904.chriscool@tuxfamily.org> On Tuesday 02 August 2011 08:28:37 Christian Couder wrote: > On Monday 01 August 2011 20:06:56 Ramkumar Ramachandra wrote: > > +static void verify_opt_compatible(const char *me, const char *base_opt, > > ...) +{ > > + const char *this_opt; > > + va_list ap; > > + int set; > > + > > + va_start(ap, base_opt); > > + while ((this_opt = va_arg(ap, const char *))) { > > + set = va_arg(ap, int); > > + if (set) { > > + va_end(ap); > > + die(_("%s: %s cannot be used with %s"), > > + me, this_opt, base_opt); > > + } > > + } > > + va_end(ap); > > +} > > Here I'd suggest: > > static void verify_opt_compatible(const char *me, const char *base_opt, > ...) { > const char *this_opt; > va_list ap; > > va_start(ap, base_opt); > while ((this_opt = va_arg(ap, const char *))) { > int set = va_arg(ap, int); > if (set) > break; > } > va_end(ap); > > if (this_opt) > die(_("%s: %s cannot be used with %s"), me, this_opt, base_opt); > } ... and we could remove the "set" variable like this: while ((this_opt = va_arg(ap, const char *))) { if (va_arg(ap, int)) break; } This could be done in verify_opt_mutually_compatible() too. Thanks, Christian.