summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@gmail.com>2015-10-28 22:59:01 +0530
committerSusant Sahani <ssahani@gmail.com>2015-10-28 22:59:01 +0530
commit6cbe4ed1e11fd2916f9dde39b27c70ffa6ba01d9 (patch)
treee1bff63cb488c9e9907b65ac8e647a29b4f99ae8 /src
parent03da651313621aeffac06409b19151e9e6a0c329 (diff)
nspwan: port to extract_first_word
Diffstat (limited to 'src')
-rw-r--r--src/nspawn/nspawn.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 8140cda141..44f08ab1b4 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -387,6 +387,7 @@ static int parse_argv(int argc, char *argv[]) {
};
int c, r;
+ const char *p;
uint64_t plus = 0, minus = 0;
bool mask_all_settings = false, mask_no_settings = false;
@@ -524,15 +525,16 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_CAPABILITY:
case ARG_DROP_CAPABILITY: {
- const char *state, *word;
- size_t length;
+ p = optarg;
+ for(;;) {
+ _cleanup_free_ char *t = NULL;
- FOREACH_WORD_SEPARATOR(word, length, optarg, ",", state) {
- _cleanup_free_ char *t;
+ r = extract_first_word(&p, &t, ",", 0);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse capability %s.", t);
- t = strndup(word, length);
- if (!t)
- return log_oom();
+ if (r == 0)
+ break;
if (streq(t, "all")) {
if (c == ARG_CAPABILITY)