Thread (12 messages) flat view 12 messages, 2 authors, 2016-06-15
DORMANTno replies

Revision v3 of 4 in this series.

Revisions (4)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 current
  4. v4 [diff vs current]

[PATCH v3 1/5] parse-options: Allow PARSE_OPT_NOARG in integer arguments

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:49:21
Subsystem: the rest · Maintainer: Linus Torvalds

When the option parser encounters an OPTION_INTEGER argument,
PARSE_OPT_NOARG should imply that the default value should be used.

Signed-off-by: Ramkumar Ramachandra <redacted>
Cc: Jakub Narebski <redacted>
---
 parse-options.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index e0c3641..7ec9886 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -138,6 +138,9 @@ static int get_value(struct parse_opt_ctx_t *p,
 			*(int *)opt->value = 0;
 			return 0;
 		}
+		if (opt->flags & PARSE_OPT_NOARG)
+			*(int *)opt->value = opt->defval;
+			return 0;
 		if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
 			*(int *)opt->value = opt->defval;
 			return 0;
-- 
1.7.2.2.409.gdbb11.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help