[PATCH 4/9] option: extract OPTION_NUMERIC() from handle_switch_fmemcpy_max_count()

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

 



Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 lib.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib.c b/lib.c
index 992fdb49a..5fda4b029 100644
--- a/lib.c
+++ b/lib.c
@@ -509,6 +509,25 @@ static int handle_simple_switch(const char *arg, const struct flag *flags)
 	return 0;
 }
 
+#define OPT_NUMERIC(NAME, TYPE, FUNCTION)	\
+static int opt_##NAME(char *arg, const char *name, TYPE *ptr)	\
+{									\
+	char *opt;							\
+	char *end;							\
+	TYPE val;							\
+									\
+	if (!(opt = match_option(arg, name+2)))				\
+		return 0;						\
+	opt++; /* opt's last char is '=' */				\
+	val = FUNCTION(opt, &end, 0);					\
+	if (*end != '\0' || end == opt) {				\
+			die("error: missing argument to \"%s\"", name);	\
+	}								\
+	*ptr = val;							\
+	return 1;							\
+}
+
+
 static char **handle_switch_o(char *arg, char **next)
 {
 	if (!strcmp (arg, "o")) {       // "-o foo"
-- 
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



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux