On Fri, Mar 1, 2019 at 2:09 PM Jeff King <peff@xxxxxxxx> wrote: > I think you want an "OR". Or even separate conditions, since really this > is just implying OPT_NEG(). In fact, you could implement and explain it > like this: > > diff --git a/parse-options.h b/parse-options.h > index 14fe32428e..d46f89305c 100644 > --- a/parse-options.h > +++ b/parse-options.h > @@ -202,6 +202,18 @@ const char *optname(const struct option *opt, int flags); > BUG("option callback does not expect an argument"); \ > } while (0) > > +/* > + * Similar to the assertions above, but checks that "arg" is always non-NULL. > + * I.e., that we expect the NOARG and OPTARG flags _not_ to be set. Since > + * negation is the other common cause of a NULL arg, this also implies > + * BUG_ON_OPT_NEG(), letting you declare both assertions in a single line. > + */ > +#define BUG_ON_OPT_NOARG(unset, arg) do { \ > + BUG_ON_OPT_NEG(unset); \ > + if (!(arg)) \ > + BUG("option callback require an argument"); \ > +} while (0) > + > /*----- incremental advanced APIs -----*/ Ahh yes. I had originally used ((!unset) || (!arg)), and second guessed myself before I submitted v2. However, I much prefer your solution which reuses BUG_ON_OPT_NEG(). I'll switch to that :-) Brandon