For some options with a numerical value, it is sometimes desirable, when the value is used to limits something, to easily specify we want to remove any limits. This patch allow to use 'unlimited' for this by interpreting it as the maximum value. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- lib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib.c b/lib.c index 6352b4e93..4c210d58f 100644 --- a/lib.c +++ b/lib.c @@ -511,6 +511,7 @@ static int handle_simple_switch(const char *arg, const struct flag *flags) #define OPTNUM_ZERO_IS_INF 1 +#define OPTNUM_UNLIMITED 2 #define OPT_NUMERIC(NAME, TYPE, FUNCTION) \ static int opt_##NAME(char *arg, const char *name, TYPE *ptr, int flag) \ @@ -524,6 +525,9 @@ static int opt_##NAME(char *arg, const char *name, TYPE *ptr, int flag) \ opt++; /* opt's last char is '=' */ \ val = FUNCTION(opt, &end, 0); \ if (*end != '\0' || end == opt) { \ + if ((flag & OPTNUM_UNLIMITED) && !strcmp(opt, "unlimited")) \ + val = ~val; \ + else \ die("error: missing argument to \"%s\"", name); \ } \ if ((flag & OPTNUM_ZERO_IS_INF) && val == 0) \ -- 2.14.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html