tools: fix usage of boolean function set_config_item

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
This commit is contained in:
Felix Abecassis 2018-03-13 21:50:46 -07:00
parent 93936fbc7b
commit e2eae70354
4 changed files with 14 additions and 14 deletions

View File

@ -194,8 +194,8 @@ int main(int argc, char *argv[])
} }
} }
ret = lxc_config_define_load(&defines, c); bret = lxc_config_define_load(&defines, c);
if (ret) { if (!bret) {
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -209,8 +209,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = c->set_config_item(c, "lxc.init.uid", buf); bret = c->set_config_item(c, "lxc.init.uid", buf);
if (ret < 0) { if (!bret) {
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -225,8 +225,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = c->set_config_item(c, "lxc.init.gid", buf); bret = c->set_config_item(c, "lxc.init.gid", buf);
if (ret < 0) { if (!bret) {
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -277,7 +277,7 @@ int main(int argc, char *argv[])
goto out; goto out;
} }
if (lxc_config_define_load(&defines, c)) if (!lxc_config_define_load(&defines, c))
goto out; goto out;
if (!rcfile && !strcmp("/sbin/init", args[0])) { if (!rcfile && !strcmp("/sbin/init", args[0])) {

View File

@ -800,20 +800,20 @@ int lxc_config_define_add(struct lxc_list *defines, char *arg)
return 0; return 0;
} }
int lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c) bool lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c)
{ {
struct lxc_list *it; struct lxc_list *it;
int ret = 0; bool bret = true;
lxc_list_for_each(it, defines) { lxc_list_for_each(it, defines) {
struct new_config_item *new_item = it->elem; struct new_config_item *new_item = it->elem;
ret = c->set_config_item(c, new_item->key, new_item->val); bret = c->set_config_item(c, new_item->key, new_item->val);
if (ret < 0) if (!bret)
break; break;
} }
lxc_config_define_free(defines); lxc_config_define_free(defines);
return ret; return bret;
} }
void lxc_config_define_free(struct lxc_list *defines) void lxc_config_define_free(struct lxc_list *defines)

View File

@ -160,7 +160,7 @@ extern char *get_template_path(const char *t);
extern bool switch_to_ns(pid_t pid, const char *ns); extern bool switch_to_ns(pid_t pid, const char *ns);
extern int lxc_config_define_add(struct lxc_list *defines, char *arg); extern int lxc_config_define_add(struct lxc_list *defines, char *arg);
extern int lxc_config_define_load(struct lxc_list *defines, extern bool lxc_config_define_load(struct lxc_list *defines,
struct lxc_container *c); struct lxc_container *c);
extern void lxc_config_define_free(struct lxc_list *defines); extern void lxc_config_define_free(struct lxc_list *defines);
extern int lxc_char_left_gc(const char *buffer, size_t len); extern int lxc_char_left_gc(const char *buffer, size_t len);