Unverified Commit d05b59aa by 2xsec Committed by Christian Brauner

tree-wide: coding style fixes

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com> [christian.brauner@ubuntu.com: cleanup if-branches in confile.c] Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 2caf13c3
...@@ -1212,7 +1212,7 @@ static int lxc_cmd_accept(int fd, uint32_t events, void *data, ...@@ -1212,7 +1212,7 @@ static int lxc_cmd_accept(int fd, uint32_t events, void *data,
connection = accept(fd, NULL, 0); connection = accept(fd, NULL, 0);
if (connection < 0) { if (connection < 0) {
SYSERROR("Failed to accept connection to run command."); SYSERROR("Failed to accept connection to run command");
return LXC_MAINLOOP_ERROR; return LXC_MAINLOOP_ERROR;
} }
......
...@@ -120,7 +120,7 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen, ...@@ -120,7 +120,7 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen,
* Although null termination isn't required by the API, we do it anyway * Although null termination isn't required by the API, we do it anyway
* because we print the sockname out sometimes. * because we print the sockname out sometimes.
*/ */
len = pathlen -2; len = pathlen - 2;
name = lxcname; name = lxcname;
if (!name) if (!name)
...@@ -220,6 +220,6 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler, ...@@ -220,6 +220,6 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
return state; return state;
} }
TRACE("added state client %d to state client list", state_client_fd); TRACE("Added state client %d to state client list", state_client_fd);
return MAX_STATE; return MAX_STATE;
} }
...@@ -286,7 +286,7 @@ static int set_config_net_type(const char *key, const char *value, ...@@ -286,7 +286,7 @@ static int set_config_net_type(const char *key, const char *value,
} else if (!strcmp(value, "none")) { } else if (!strcmp(value, "none")) {
netdev->type = LXC_NET_NONE; netdev->type = LXC_NET_NONE;
} else { } else {
ERROR("invalid network type %s", value); ERROR("Invalid network type %s", value);
return -1; return -1;
} }
...@@ -320,13 +320,14 @@ static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf, ...@@ -320,13 +320,14 @@ static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf,
const char *tmpvalue = "phys"; const char *tmpvalue = "phys";
if (netns_getifaddrs(&ifaddr, -1, &(bool){false}) < 0) { if (netns_getifaddrs(&ifaddr, -1, &(bool){false}) < 0) {
SYSERROR("Get network interfaces failed"); SYSERROR("Failed to get network interfaces");
return -1; return -1;
} }
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
if (!ifa->ifa_addr) if (!ifa->ifa_addr)
continue; continue;
if (ifa->ifa_addr->sa_family != AF_PACKET) if (ifa->ifa_addr->sa_family != AF_PACKET)
continue; continue;
...@@ -337,11 +338,11 @@ static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf, ...@@ -337,11 +338,11 @@ static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf,
ret = set_config_net_link( ret = set_config_net_link(
link_key, ifa->ifa_name, lxc_conf, netdev); link_key, ifa->ifa_name, lxc_conf, netdev);
if (ret) { if (ret) {
ERROR("failed to create matched ifnames"); ERROR("Failed to create matched ifnames");
break; break;
} }
} else { } else {
ERROR("failed to create matched ifnames"); ERROR("Failed to create matched ifnames");
break; break;
} }
} }
...@@ -440,6 +441,7 @@ static int set_config_net_hwaddr(const char *key, const char *value, ...@@ -440,6 +441,7 @@ static int set_config_net_hwaddr(const char *key, const char *value,
} }
netdev->hwaddr = new_value; netdev->hwaddr = new_value;
return 0; return 0;
} }
...@@ -495,7 +497,6 @@ static int set_config_net_ipv4_address(const char *key, const char *value, ...@@ -495,7 +497,6 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
inetdev = malloc(sizeof(*inetdev)); inetdev = malloc(sizeof(*inetdev));
if (!inetdev) if (!inetdev)
return -1; return -1;
memset(inetdev, 0, sizeof(*inetdev)); memset(inetdev, 0, sizeof(*inetdev));
list = malloc(sizeof(*list)); list = malloc(sizeof(*list));
...@@ -569,8 +570,8 @@ static int set_config_net_ipv4_address(const char *key, const char *value, ...@@ -569,8 +570,8 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
} }
lxc_list_add_tail(&netdev->ipv4, list); lxc_list_add_tail(&netdev->ipv4, list);
free(addr); free(addr);
return 0; return 0;
} }
...@@ -630,7 +631,6 @@ static int set_config_net_ipv6_address(const char *key, const char *value, ...@@ -630,7 +631,6 @@ static int set_config_net_ipv6_address(const char *key, const char *value,
inet6dev = malloc(sizeof(*inet6dev)); inet6dev = malloc(sizeof(*inet6dev));
if (!inet6dev) if (!inet6dev)
return -1; return -1;
memset(inet6dev, 0, sizeof(*inet6dev)); memset(inet6dev, 0, sizeof(*inet6dev));
list = malloc(sizeof(*list)); list = malloc(sizeof(*list));
...@@ -654,6 +654,7 @@ static int set_config_net_ipv6_address(const char *key, const char *value, ...@@ -654,6 +654,7 @@ static int set_config_net_ipv6_address(const char *key, const char *value,
if (slash) { if (slash) {
*slash = '\0'; *slash = '\0';
netmask = slash + 1; netmask = slash + 1;
ret = lxc_safe_uint(netmask, &inet6dev->prefix); ret = lxc_safe_uint(netmask, &inet6dev->prefix);
if (ret < 0) { if (ret < 0) {
free(list); free(list);
...@@ -673,8 +674,8 @@ static int set_config_net_ipv6_address(const char *key, const char *value, ...@@ -673,8 +674,8 @@ static int set_config_net_ipv6_address(const char *key, const char *value,
} }
lxc_list_add_tail(&netdev->ipv6, list); lxc_list_add_tail(&netdev->ipv6, list);
free(valdup); free(valdup);
return 0; return 0;
} }
...@@ -756,6 +757,7 @@ static int add_hook(struct lxc_conf *lxc_conf, int which, char *hook) ...@@ -756,6 +757,7 @@ static int add_hook(struct lxc_conf *lxc_conf, int which, char *hook)
hooklist->elem = hook; hooklist->elem = hook;
lxc_list_add_tail(&lxc_conf->hooks[which], hooklist); lxc_list_add_tail(&lxc_conf->hooks[which], hooklist);
return 0; return 0;
} }
...@@ -858,6 +860,7 @@ static int set_config_hooks(const char *key, const char *value, ...@@ -858,6 +860,7 @@ static int set_config_hooks(const char *key, const char *value,
return add_hook(lxc_conf, LXCHOOK_DESTROY, copy); return add_hook(lxc_conf, LXCHOOK_DESTROY, copy);
free(copy); free(copy);
return -1; return -1;
} }
...@@ -881,6 +884,7 @@ static int set_config_hooks_version(const char *key, const char *value, ...@@ -881,6 +884,7 @@ static int set_config_hooks_version(const char *key, const char *value,
} }
lxc_conf->hooks_version = tmp; lxc_conf->hooks_version = tmp;
return 0; return 0;
} }
...@@ -913,6 +917,7 @@ static int set_config_pty_max(const char *key, const char *value, ...@@ -913,6 +917,7 @@ static int set_config_pty_max(const char *key, const char *value,
return -1; return -1;
lxc_conf->pty_max = max; lxc_conf->pty_max = max;
return 0; return 0;
} }
...@@ -1009,6 +1014,7 @@ static int set_config_group(const char *key, const char *value, ...@@ -1009,6 +1014,7 @@ static int set_config_group(const char *key, const char *value,
} }
free(groups); free(groups);
return ret; return ret;
} }
...@@ -1035,6 +1041,7 @@ static int set_config_environment(const char *key, const char *value, ...@@ -1035,6 +1041,7 @@ static int set_config_environment(const char *key, const char *value,
on_error: on_error:
free(list_item); free(list_item);
return -1; return -1;
} }
...@@ -1054,6 +1061,7 @@ static int set_config_tty_max(const char *key, const char *value, ...@@ -1054,6 +1061,7 @@ static int set_config_tty_max(const char *key, const char *value,
return -1; return -1;
lxc_conf->ttys.max = nbtty; lxc_conf->ttys.max = nbtty;
return 0; return 0;
} }
...@@ -1137,6 +1145,7 @@ static int set_config_log_level(const char *key, const char *value, ...@@ -1137,6 +1145,7 @@ static int set_config_log_level(const char *key, const char *value,
* current logging. * current logging.
*/ */
lxc_conf->loglevel = newlevel; lxc_conf->loglevel = newlevel;
return lxc_log_set_level(&lxc_conf->loglevel, newlevel); return lxc_log_set_level(&lxc_conf->loglevel, newlevel);
} }
...@@ -1325,6 +1334,7 @@ static int set_config_prlimit(const char *key, const char *value, ...@@ -1325,6 +1334,7 @@ static int set_config_prlimit(const char *key, const char *value,
/* soft limit comes first in the value */ /* soft limit comes first in the value */
if (!parse_limit_value(&value, &limit_value)) if (!parse_limit_value(&value, &limit_value))
return -1; return -1;
limit.rlim_cur = limit_value; limit.rlim_cur = limit_value;
/* skip spaces and a colon */ /* skip spaces and a colon */
...@@ -1343,6 +1353,7 @@ static int set_config_prlimit(const char *key, const char *value, ...@@ -1343,6 +1353,7 @@ static int set_config_prlimit(const char *key, const char *value,
if (*value) { if (*value) {
if (!parse_limit_value(&value, &limit_value)) if (!parse_limit_value(&value, &limit_value))
return -1; return -1;
limit.rlim_max = limit_value; limit.rlim_max = limit_value;
/* check for trailing garbage */ /* check for trailing garbage */
...@@ -1378,20 +1389,21 @@ static int set_config_prlimit(const char *key, const char *value, ...@@ -1378,20 +1389,21 @@ static int set_config_prlimit(const char *key, const char *value,
limelem->resource = strdup(key); limelem->resource = strdup(key);
if (!limelem->resource) if (!limelem->resource)
goto on_error; goto on_error;
limelem->limit = limit;
limelem->limit = limit;
lxc_list_add_elem(limlist, limelem);; lxc_list_add_elem(limlist, limelem);;
lxc_list_add_tail(&lxc_conf->limits, limlist); lxc_list_add_tail(&lxc_conf->limits, limlist);
return 0; return 0;
on_error: on_error:
free(limlist); free(limlist);
if (limelem) { if (limelem) {
free(limelem->resource); free(limelem->resource);
free(limelem); free(limelem);
} }
return -1; return -1;
} }
...@@ -1424,6 +1436,7 @@ static int set_config_sysctl(const char *key, const char *value, ...@@ -1424,6 +1436,7 @@ static int set_config_sysctl(const char *key, const char *value,
free(sysctl_elem->value); free(sysctl_elem->value);
sysctl_elem->value = replace_value; sysctl_elem->value = replace_value;
return 0; return 0;
} }
...@@ -1446,18 +1459,19 @@ static int set_config_sysctl(const char *key, const char *value, ...@@ -1446,18 +1459,19 @@ static int set_config_sysctl(const char *key, const char *value,
goto on_error; goto on_error;
lxc_list_add_elem(sysctl_list, sysctl_elem); lxc_list_add_elem(sysctl_list, sysctl_elem);
lxc_list_add_tail(&lxc_conf->sysctls, sysctl_list); lxc_list_add_tail(&lxc_conf->sysctls, sysctl_list);
return 0; return 0;
on_error: on_error:
free(sysctl_list); free(sysctl_list);
if (sysctl_elem) { if (sysctl_elem) {
free(sysctl_elem->key); free(sysctl_elem->key);
free(sysctl_elem->value); free(sysctl_elem->value);
free(sysctl_elem); free(sysctl_elem);
} }
return -1; return -1;
} }
...@@ -1501,6 +1515,7 @@ static int set_config_proc(const char *key, const char *value, ...@@ -1501,6 +1515,7 @@ static int set_config_proc(const char *key, const char *value,
on_error: on_error:
free(proclist); free(proclist);
if (procelem) { if (procelem) {
free(procelem->filename); free(procelem->filename);
free(procelem->value); free(procelem->value);
...@@ -1555,7 +1570,6 @@ static int set_config_idmaps(const char *key, const char *value, ...@@ -1555,7 +1570,6 @@ static int set_config_idmaps(const char *key, const char *value,
if (idmap->nsid == 0) if (idmap->nsid == 0)
lxc_conf->root_nsuid_map = idmap; lxc_conf->root_nsuid_map = idmap;
if (!lxc_conf->root_nsgid_map && idmap->idtype == ID_TYPE_GID) if (!lxc_conf->root_nsgid_map && idmap->idtype == ID_TYPE_GID)
if (idmap->nsid == 0) if (idmap->nsid == 0)
lxc_conf->root_nsgid_map = idmap; lxc_conf->root_nsgid_map = idmap;
...@@ -1837,6 +1851,7 @@ static int set_config_console_buffer_size(const char *key, const char *value, ...@@ -1837,6 +1851,7 @@ static int set_config_console_buffer_size(const char *key, const char *value,
"next power of two: %" PRIu64 " bytes", buffer_size); "next power of two: %" PRIu64 " bytes", buffer_size);
lxc_conf->console.buffer_size = buffer_size; lxc_conf->console.buffer_size = buffer_size;
return 0; return 0;
} }
...@@ -1884,6 +1899,7 @@ static int set_config_console_size(const char *key, const char *value, ...@@ -1884,6 +1899,7 @@ static int set_config_console_size(const char *key, const char *value,
"next power of two: %" PRIu64 " bytes", log_size); "next power of two: %" PRIu64 " bytes", log_size);
lxc_conf->console.log_size = log_size; lxc_conf->console.log_size = log_size;
return 0; return 0;
} }
...@@ -1999,11 +2015,13 @@ static int set_config_rootfs_path(const char *key, const char *value, ...@@ -1999,11 +2015,13 @@ static int set_config_rootfs_path(const char *key, const char *value,
tmp = strchr(dup, ':'); tmp = strchr(dup, ':');
if (tmp) { if (tmp) {
*tmp = '\0'; *tmp = '\0';
ret = set_config_path_item(&lxc_conf->rootfs.bdev_type, dup); ret = set_config_path_item(&lxc_conf->rootfs.bdev_type, dup);
if (ret < 0) { if (ret < 0) {
free(dup); free(dup);
return -1; return -1;
} }
tmp++; tmp++;
container_path = tmp; container_path = tmp;
} else { } else {
...@@ -2012,6 +2030,7 @@ static int set_config_rootfs_path(const char *key, const char *value, ...@@ -2012,6 +2030,7 @@ static int set_config_rootfs_path(const char *key, const char *value,
ret = set_config_path_item(&lxc_conf->rootfs.path, container_path); ret = set_config_path_item(&lxc_conf->rootfs.path, container_path);
free(dup); free(dup);
return ret; return ret;
} }
...@@ -2248,6 +2267,7 @@ static int parse_line(char *buffer, void *data) ...@@ -2248,6 +2267,7 @@ static int parse_line(char *buffer, void *data)
on_error: on_error:
free(linep); free(linep);
return ret; return ret;
} }
...@@ -2348,6 +2368,7 @@ int lxc_config_define_add(struct lxc_list *defines, char *arg) ...@@ -2348,6 +2368,7 @@ int lxc_config_define_add(struct lxc_list *defines, char *arg)
} }
lxc_list_add_tail(defines, dent); lxc_list_add_tail(defines, dent);
return 0; return 0;
} }
...@@ -2364,6 +2385,7 @@ bool lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c) ...@@ -2364,6 +2385,7 @@ bool lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c)
} }
lxc_config_define_free(defines); lxc_config_define_free(defines);
return bret; return bret;
} }
...@@ -2519,14 +2541,17 @@ void clear_unexp_config_line(struct lxc_conf *conf, const char *key, ...@@ -2519,14 +2541,17 @@ void clear_unexp_config_line(struct lxc_conf *conf, const char *key,
while (*lstart) { while (*lstart) {
lend = strchr(lstart, '\n'); lend = strchr(lstart, '\n');
char v; char v;
if (!lend) if (!lend)
lend = lstart + strlen(lstart); lend = lstart + strlen(lstart);
else else
lend++; lend++;
if (strncmp(lstart, key, strlen(key)) != 0) { if (strncmp(lstart, key, strlen(key)) != 0) {
lstart = lend; lstart = lend;
continue; continue;
} }
if (!rm_subkeys) { if (!rm_subkeys) {
v = lstart[strlen(key)]; v = lstart[strlen(key)];
if (!isspace(v) && v != '=') { if (!isspace(v) && v != '=') {
...@@ -2534,11 +2559,14 @@ void clear_unexp_config_line(struct lxc_conf *conf, const char *key, ...@@ -2534,11 +2559,14 @@ void clear_unexp_config_line(struct lxc_conf *conf, const char *key,
continue; continue;
} }
} }
conf->unexpanded_len -= (lend - lstart); conf->unexpanded_len -= (lend - lstart);
if (*lend == '\0') { if (*lend == '\0') {
*lstart = '\0'; *lstart = '\0';
return; return;
} }
memmove(lstart, lend, strlen(lend) + 1); memmove(lstart, lend, strlen(lend) + 1);
} }
} }
...@@ -2610,6 +2638,7 @@ bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath, ...@@ -2610,6 +2638,7 @@ bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath,
if (olddirlen >= newdirlen) { if (olddirlen >= newdirlen) {
size_t diff = olddirlen - newdirlen; size_t diff = olddirlen - newdirlen;
memcpy(q, newdir, newdirlen); memcpy(q, newdir, newdirlen);
if (olddirlen != newdirlen) { if (olddirlen != newdirlen) {
memmove(q + newdirlen, q + newdirlen + diff, memmove(q + newdirlen, q + newdirlen + diff,
strlen(q) - newdirlen - diff + 1); strlen(q) - newdirlen - diff + 1);
...@@ -2631,15 +2660,18 @@ bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath, ...@@ -2631,15 +2660,18 @@ bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath,
conf->unexpanded_alloced = newlen + 1; conf->unexpanded_alloced = newlen + 1;
new[newlen - 1] = '\0'; new[newlen - 1] = '\0';
lend = new + (lend - conf->unexpanded_config); lend = new + (lend - conf->unexpanded_config);
/* Move over the remainder to make room for the newdir. /* Move over the remainder to make room for the newdir.
*/ */
memmove(new + poffset + newdirlen, memmove(new + poffset + newdirlen,
new + poffset + olddirlen, new + poffset + olddirlen,
oldlen - poffset - olddirlen + 1); oldlen - poffset - olddirlen + 1);
conf->unexpanded_config = new; conf->unexpanded_config = new;
memcpy(new + poffset, newdir, newdirlen); memcpy(new + poffset, newdir, newdirlen);
lend += diff; lend += diff;
} }
next: next:
lstart = lend; lstart = lend;
} }
...@@ -2700,6 +2732,7 @@ bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath, ...@@ -2700,6 +2732,7 @@ bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath,
if (olddirlen >= newdirlen) { if (olddirlen >= newdirlen) {
size_t diff = olddirlen - newdirlen; size_t diff = olddirlen - newdirlen;
memcpy(p, newdir, newdirlen); memcpy(p, newdir, newdirlen);
if (olddirlen != newdirlen) { if (olddirlen != newdirlen) {
memmove(p + newdirlen, p + newdirlen + diff, memmove(p + newdirlen, p + newdirlen + diff,
strlen(p) - newdirlen - diff + 1); strlen(p) - newdirlen - diff + 1);
...@@ -2721,15 +2754,18 @@ bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath, ...@@ -2721,15 +2754,18 @@ bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath,
conf->unexpanded_alloced = newlen + 1; conf->unexpanded_alloced = newlen + 1;
new[newlen - 1] = '\0'; new[newlen - 1] = '\0';
lend = new + (lend - conf->unexpanded_config); lend = new + (lend - conf->unexpanded_config);
/* Move over the remainder to make room for the newdir. /* Move over the remainder to make room for the newdir.
*/ */
memmove(new + poffset + newdirlen, memmove(new + poffset + newdirlen,
new + poffset + olddirlen, new + poffset + olddirlen,
oldlen - poffset - olddirlen + 1); oldlen - poffset - olddirlen + 1);
conf->unexpanded_config = new; conf->unexpanded_config = new;
memcpy(new + poffset, newdir, newdirlen); memcpy(new + poffset, newdir, newdirlen);
lend += diff; lend += diff;
} }
next: next:
lstart = lend; lstart = lend;
} }
...@@ -2852,6 +2888,7 @@ static int set_config_log_syslog(const char *key, const char *value, ...@@ -2852,6 +2888,7 @@ static int set_config_log_syslog(const char *key, const char *value,
return -1; return -1;
lxc_log_syslog(facility); lxc_log_syslog(facility);
return set_config_string_item(&lxc_conf->syslog, value); return set_config_string_item(&lxc_conf->syslog, value);
} }
...@@ -2993,9 +3030,9 @@ static int __get_config_cgroup_controller(const char *key, char *retv, ...@@ -2993,9 +3030,9 @@ static int __get_config_cgroup_controller(const char *key, char *retv,
if (version != cg->version) if (version != cg->version)
continue; continue;
strprint(retv, inlen, "%s.%s = %s\n", strprint(retv, inlen, "%s.%s = %s\n", global_token,
global_token, cg->subsystem, cg->value); cg->subsystem, cg->value);
} else if (!strcmp(cg->subsystem, key)) { } else if (strcmp(cg->subsystem, key) == 0) {
strprint(retv, inlen, "%s\n", cg->value); strprint(retv, inlen, "%s\n", cg->value);
} }
} }
...@@ -3078,6 +3115,7 @@ static int get_config_idmaps(const char *key, char *retv, int inlen, ...@@ -3078,6 +3115,7 @@ static int get_config_idmaps(const char *key, char *retv, int inlen,
strprint(retv, inlen, "%s%s", buf, (listlen-- > 1) ? "\n" : ""); strprint(retv, inlen, "%s%s", buf, (listlen-- > 1) ? "\n" : "");
} }
return fulllen; return fulllen;
} }
...@@ -3230,19 +3268,21 @@ static int get_config_hooks(const char *key, char *retv, int inlen, ...@@ -3230,19 +3268,21 @@ static int get_config_hooks(const char *key, char *retv, int inlen,
int i; int i;
subkey = strchr(key, '.'); subkey = strchr(key, '.');
if (subkey)
subkey = strchr(subkey + 1, '.');
if (!subkey) if (!subkey)
return -1; return -1;
subkey = strchr(subkey + 1, '.');
subkey++; subkey++;
if (!*subkey) if (!*subkey)
return -1; return -1;
for (i = 0; i < NUM_LXC_HOOKS; i++) { for (i = 0; i < NUM_LXC_HOOKS; i++) {
if (strcmp(lxchook_names[i], subkey) == 0) { if (strcmp(lxchook_names[i], subkey) == 0) {
found = i; found = i;
break; break;
} }
} }
if (found == -1) if (found == -1)
return -1; return -1;
...@@ -3254,6 +3294,7 @@ static int get_config_hooks(const char *key, char *retv, int inlen, ...@@ -3254,6 +3294,7 @@ static int get_config_hooks(const char *key, char *retv, int inlen,
lxc_list_for_each(it, &c->hooks[found]) { lxc_list_for_each(it, &c->hooks[found]) {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
return fulllen; return fulllen;
} }
...@@ -3521,6 +3562,7 @@ static int get_config_prlimit(const char *key, char *retv, int inlen, ...@@ -3521,6 +3562,7 @@ static int get_config_prlimit(const char *key, char *retv, int inlen,
partlen = sprintf(buf, "%" PRIu64, partlen = sprintf(buf, "%" PRIu64,
(uint64_t)lim->limit.rlim_cur); (uint64_t)lim->limit.rlim_cur);
} }
if (lim->limit.rlim_cur != lim->limit.rlim_max) { if (lim->limit.rlim_cur != lim->limit.rlim_max) {
if (lim->limit.rlim_max == RLIM_INFINITY) if (lim->limit.rlim_max == RLIM_INFINITY)
memcpy(buf + partlen, ":unlimited", memcpy(buf + partlen, ":unlimited",
...@@ -3533,7 +3575,7 @@ static int get_config_prlimit(const char *key, char *retv, int inlen, ...@@ -3533,7 +3575,7 @@ static int get_config_prlimit(const char *key, char *retv, int inlen,
if (get_all) { if (get_all) {
strprint(retv, inlen, "lxc.prlimit.%s = %s\n", strprint(retv, inlen, "lxc.prlimit.%s = %s\n",
lim->resource, buf); lim->resource, buf);
} else if (!strcmp(lim->resource, key)) { } else if (strcmp(lim->resource, key) == 0) {
strprint(retv, inlen, "%s", buf); strprint(retv, inlen, "%s", buf);
} }
} }
...@@ -3568,8 +3610,8 @@ static int get_config_sysctl(const char *key, char *retv, int inlen, ...@@ -3568,8 +3610,8 @@ static int get_config_sysctl(const char *key, char *retv, int inlen,
lxc_list_for_each(it, &c->sysctls) { lxc_list_for_each(it, &c->sysctls) {
struct lxc_sysctl *elem = it->elem; struct lxc_sysctl *elem = it->elem;
if (get_all) { if (get_all) {
strprint(retv, inlen, "lxc.sysctl.%s = %s\n", strprint(retv, inlen, "lxc.sysctl.%s = %s\n", elem->key,
elem->key, elem->value); elem->value);
} else if (strcmp(elem->key, key) == 0) { } else if (strcmp(elem->key, key) == 0) {
strprint(retv, inlen, "%s", elem->value); strprint(retv, inlen, "%s", elem->value);
} }
...@@ -4212,6 +4254,7 @@ static int set_config_net_nic(const char *key, const char *value, ...@@ -4212,6 +4254,7 @@ static int set_config_net_nic(const char *key, const char *value,
ret = config->set(deindexed_key, value, lxc_conf, netdev); ret = config->set(deindexed_key, value, lxc_conf, netdev);
free(deindexed_key); free(deindexed_key);
return ret; return ret;
} }
...@@ -4257,6 +4300,7 @@ static int clr_config_net_nic(const char *key, struct lxc_conf *lxc_conf, ...@@ -4257,6 +4300,7 @@ static int clr_config_net_nic(const char *key, struct lxc_conf *lxc_conf,
ret = config->clr(deindexed_key, lxc_conf, netdev); ret = config->clr(deindexed_key, lxc_conf, netdev);
free(deindexed_key); free(deindexed_key);
return ret; return ret;
} }
...@@ -4500,6 +4544,7 @@ static int get_config_net_nic(const char *key, char *retv, int inlen, ...@@ -4500,6 +4544,7 @@ static int get_config_net_nic(const char *key, char *retv, int inlen,
ret = config->get(deindexed_key, retv, inlen, c, netdev); ret = config->get(deindexed_key, retv, inlen, c, netdev);
free(deindexed_key); free(deindexed_key);
return ret; return ret;
} }
...@@ -4806,6 +4851,7 @@ static int get_config_net_ipv4_address(const char *key, char *retv, int inlen, ...@@ -4806,6 +4851,7 @@ static int get_config_net_ipv4_address(const char *key, char *retv, int inlen,
return -1; return -1;
listlen = lxc_list_len(&netdev->ipv4); listlen = lxc_list_len(&netdev->ipv4);
lxc_list_for_each(it, &netdev->ipv4) { lxc_list_for_each(it, &netdev->ipv4) {
struct lxc_inetdev *i = it->elem; struct lxc_inetdev *i = it->elem;
inet_ntop(AF_INET, &i->addr, buf, sizeof(buf)); inet_ntop(AF_INET, &i->addr, buf, sizeof(buf));
...@@ -4861,6 +4907,7 @@ static int get_config_net_ipv6_address(const char *key, char *retv, int inlen, ...@@ -4861,6 +4907,7 @@ static int get_config_net_ipv6_address(const char *key, char *retv, int inlen,
return -1; return -1;
listlen = lxc_list_len(&netdev->ipv6); listlen = lxc_list_len(&netdev->ipv6);
lxc_list_for_each(it, &netdev->ipv6) { lxc_list_for_each(it, &netdev->ipv6) {
struct lxc_inet6dev *i = it->elem; struct lxc_inet6dev *i = it->elem;
inet_ntop(AF_INET6, &i->addr, buf, sizeof(buf)); inet_ntop(AF_INET6, &i->addr, buf, sizeof(buf));
...@@ -4986,6 +5033,7 @@ int lxc_list_net(struct lxc_conf *c, const char *key, char *retv, int inlen) ...@@ -4986,6 +5033,7 @@ int lxc_list_net(struct lxc_conf *c, const char *key, char *retv, int inlen)
strprint(retv, inlen, "type\n"); strprint(retv, inlen, "type\n");
strprint(retv, inlen, "script.up\n"); strprint(retv, inlen, "script.up\n");
strprint(retv, inlen, "script.down\n"); strprint(retv, inlen, "script.down\n");
if (netdev->type != LXC_NET_EMPTY) { if (netdev->type != LXC_NET_EMPTY) {
strprint(retv, inlen, "flags\n"); strprint(retv, inlen, "flags\n");
strprint(retv, inlen, "link\n"); strprint(retv, inlen, "link\n");
......
...@@ -79,7 +79,7 @@ int lxc_monitor_fifo_name(const char *lxcpath, char *fifo_path, size_t fifo_path ...@@ -79,7 +79,7 @@ int lxc_monitor_fifo_name(const char *lxcpath, char *fifo_path, size_t fifo_path
} }
ret = mkdir_p(fifo_path, 0755); ret = mkdir_p(fifo_path, 0755);
if (ret < 0) { if (ret < 0) {
ERROR("Unable to create monitor fifo directory %s.", fifo_path); ERROR("Unable to create monitor fifo directory %s", fifo_path);
free(rundir); free(rundir);
return ret; return ret;
} }
......
...@@ -34,7 +34,6 @@ int lxc_raw_execveat(int dirfd, const char *pathname, char *const argv[], ...@@ -34,7 +34,6 @@ int lxc_raw_execveat(int dirfd, const char *pathname, char *const argv[],
*/ */
pid_t lxc_raw_clone(unsigned long flags) pid_t lxc_raw_clone(unsigned long flags)
{ {
/* /*
* These flags don't interest at all so we don't jump through any hoopes * These flags don't interest at all so we don't jump through any hoopes
* of retrieving them and passing them to the kernel. * of retrieving them and passing them to the kernel.
......
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