freezer: non-functional changes

Fix the coding style in a few files. Fixes: db1228b3 ("Avoid hardcoded string length") Fixes: 71fc9c04 ("Avoid risk of "too far memory read"") Fixes: 2341916a ("Avoid double lxc-freeze/unfreeze") Fixes: 9eb9ce3e ("Update freezer.c") Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 3309e10c
...@@ -65,19 +65,21 @@ static int do_freeze_thaw(bool freeze, struct lxc_conf *conf, const char *name, ...@@ -65,19 +65,21 @@ static int do_freeze_thaw(bool freeze, struct lxc_conf *conf, const char *name,
ret = cgroup_ops->set(cgroup_ops, "freezer.state", state, name, lxcpath); ret = cgroup_ops->set(cgroup_ops, "freezer.state", state, name, lxcpath);
if (ret < 0) { if (ret < 0) {
cgroup_exit(cgroup_ops); cgroup_exit(cgroup_ops);
ERROR("Failed to %s %s", (new_state == FROZEN ? "freeze" : "unfreeze"), name); ERROR("Failed to %s %s",
(new_state == FROZEN ? "freeze" : "unfreeze"), name);
return -1; return -1;
} }
for (;;) { for (;;) {
ret = cgroup_ops->get(cgroup_ops, "freezer.state", v, sizeof(v), name, lxcpath); ret = cgroup_ops->get(cgroup_ops, "freezer.state", v, sizeof(v),
name, lxcpath);
if (ret < 0) { if (ret < 0) {
cgroup_exit(cgroup_ops); cgroup_exit(cgroup_ops);
ERROR("Failed to get freezer state of %s", name); ERROR("Failed to get freezer state of %s", name);
return -1; return -1;
} }
v[sizeof(v)-1] = '\0'; v[sizeof(v) - 1] = '\0';
v[lxc_char_right_gc(v, strlen(v))] = '\0'; v[lxc_char_right_gc(v, strlen(v))] = '\0';
ret = strncmp(v, state, state_len); ret = strncmp(v, state, state_len);
......
...@@ -527,15 +527,12 @@ static bool do_lxcapi_freeze(struct lxc_container *c) ...@@ -527,15 +527,12 @@ static bool do_lxcapi_freeze(struct lxc_container *c)
int ret; int ret;
lxc_state_t s; lxc_state_t s;
if (!c) if (!c || !c->lxc_conf)
return false; return false;
s = lxc_getstate(c->name, c->config_path); s = lxc_getstate(c->name, c->config_path);
if (s != FROZEN) { if (s != FROZEN)
ret = lxc_freeze(c->lxc_conf, c->name, c->config_path); return lxc_freeze(c->lxc_conf, c->name, c->config_path) == 0;
if (ret < 0)
return false;
}
return true; return true;
} }
...@@ -547,15 +544,12 @@ static bool do_lxcapi_unfreeze(struct lxc_container *c) ...@@ -547,15 +544,12 @@ static bool do_lxcapi_unfreeze(struct lxc_container *c)
int ret; int ret;
lxc_state_t s; lxc_state_t s;
if (!c) if (!c || !c->lxc_conf)
return false; return false;
s = lxc_getstate(c->name, c->config_path); s = lxc_getstate(c->name, c->config_path);
if (s == FROZEN) { if (s == FROZEN)
ret = lxc_unfreeze(c->lxc_conf, c->name, c->config_path); return lxc_unfreeze(c->lxc_conf, c->name, c->config_path) == 0;
if (ret < 0)
return false;
}
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment