return log_error_errno(-1, errno, "Failed to set environment variable: LXC_HOOK_SECTION=%s", section);
TRACE("Set environment variable: LXC_HOOK_SECTION=%s", section);
- if (strcmp(section, "net") == 0) {
+ if (strequal(section, "net")) {
char *parent;
if (!argv || !argv[0])
parent = argv[1] ? argv[1] : "";
- if (strcmp(argv[0], "macvlan") == 0) {
+ if (strequal(argv[0], "macvlan")) {
ret = setenv("LXC_NET_PARENT", parent, 1);
if (ret < 0)
return log_error_errno(-1, errno, "Failed to set environment variable: LXC_NET_PARENT=%s", parent);
TRACE("Set environment variable: LXC_NET_PARENT=%s", parent);
- } else if (strcmp(argv[0], "phys") == 0) {
+ } else if (strequal(argv[0], "phys")) {
ret = setenv("LXC_NET_PARENT", parent, 1);
if (ret < 0)
return log_error_errno(-1, errno, "Failed to set environment variable: LXC_NET_PARENT=%s", parent);
TRACE("Set environment variable: LXC_NET_PARENT=%s", parent);
- } else if (strcmp(argv[0], "veth") == 0) {
+ } else if (strequal(argv[0], "veth")) {
char *peer = argv[2] ? argv[2] : "";
ret = setenv("LXC_NET_PEER", peer, 1);
if (rootfs->path) {
if (rootfs->bdev_type &&
- (!strcmp(rootfs->bdev_type, "overlay") ||
- !strcmp(rootfs->bdev_type, "overlayfs")))
+ (strequal(rootfs->bdev_type, "overlay") ||
+ strequal(rootfs->bdev_type, "overlayfs")))
return log_trace_errno(0, EINVAL, "Not pinning on stacking filesystem");
dfd_path = open_at(-EBADF, rootfs->path, PROTECT_OPATH_FILE, 0, 0);
*slider2 = '\0';
*slider1 = '.';
- if (strcmp(slider1 + 1, "/") == 0)
+ if (strequal(slider1 + 1, "/"))
continue;
- if (strcmp(slider1 + 1, "/proc") == 0)
+ if (strequal(slider1 + 1, "/proc"))
continue;
ret = umount2(slider1, MNT_DETACH);
static inline bool wants_console(const struct lxc_terminal *terminal)
{
- return !terminal->path || strcmp(terminal->path, "none");
+ return !terminal->path || !strequal(terminal->path, "none");
}
static int lxc_bind_mount_console(const struct lxc_terminal *console,
size_t end = sizeof(caps_opt) / sizeof(caps_opt[0]);
char *ptr = NULL;
- if (strcmp(cap, "none") == 0)
+ if (strequal(cap, "none"))
return -2;
for (i = 0; i < end; i++) {
- if (strcmp(cap, caps_opt[i].name))
+ if (!strequal(cap, caps_opt[i].name))
continue;
capid = caps_opt[i].value;
int resid = -1;
for (i = 0; i < sizeof(limit_opt) / sizeof(limit_opt[0]); ++i)
- if (strcmp(res, limit_opt[i].name) == 0)
+ if (strequal(res, limit_opt[i].name))
return limit_opt[i].value;
/* Try to see if it's numeric, so the user may specify
int which;
for (which = 0; which < NUM_LXC_HOOKS; which ++) {
- if (strcmp(hookname, lxchook_names[which]) == 0)
+ if (strequal(hookname, lxchook_names[which]))
break;
}
return -EINVAL;
}
- if (strcmp(key, global_token) == 0)
+ if (strequal(key, global_token))
all = true;
else if (strncmp(key, namespaced_token, namespaced_token_len) == 0)
k += namespaced_token_len;
lxc_list_for_each_safe (it, list, next) {
struct lxc_cgroup *cg = it->elem;
- if (!all && strcmp(cg->subsystem, k) != 0)
+ if (!all && !strequal(cg->subsystem, k))
continue;
lxc_list_del(it);
const char *k = NULL;
bool all = false;
- if (strcmp(key, "lxc.limit") == 0 || strcmp(key, "lxc.prlimit") == 0)
+ if (strequal(key, "lxc.limit") || strequal(key, "lxc.prlimit"))
all = true;
else if (strncmp(key, "lxc.limit.", STRLITERALLEN("lxc.limit.")) == 0)
k = key + STRLITERALLEN("lxc.limit.");
lxc_list_for_each_safe (it, &c->limits, next) {
struct lxc_limit *lim = it->elem;
- if (!all && strcmp(lim->resource, k) != 0)
+ if (!all && !strequal(lim->resource, k))
continue;
lxc_list_del(it);
const char *k = NULL;
bool all = false;
- if (strcmp(key, "lxc.sysctl") == 0)
+ if (strequal(key, "lxc.sysctl"))
all = true;
else if (strncmp(key, "lxc.sysctl.", STRLITERALLEN("lxc.sysctl.")) == 0)
k = key + STRLITERALLEN("lxc.sysctl.");
lxc_list_for_each_safe (it, &c->sysctls, next) {
struct lxc_sysctl *elem = it->elem;
- if (!all && strcmp(elem->key, k) != 0)
+ if (!all && !strequal(elem->key, k))
continue;
lxc_list_del(it);
const char *k = NULL;
bool all = false;
- if (strcmp(key, "lxc.proc") == 0)
+ if (strequal(key, "lxc.proc"))
all = true;
else if (strncmp(key, "lxc.proc.", STRLITERALLEN("lxc.proc.")) == 0)
k = key + STRLITERALLEN("lxc.proc.");
lxc_list_for_each_safe (it, &c->procs, next) {
struct lxc_proc *proc = it->elem;
- if (!all && strcmp(proc->filename, k) != 0)
+ if (!all && !strequal(proc->filename, k))
continue;
lxc_list_del(it);
const char *k = NULL;
bool all = false, done = false;
- if (strcmp(key, "lxc.hook") == 0)
+ if (strequal(key, "lxc.hook"))
all = true;
else if (strncmp(key, "lxc.hook.", STRLITERALLEN("lxc.hook.")) == 0)
k = key + STRLITERALLEN("lxc.hook.");
return -1;
for (i = 0; i < NUM_LXC_HOOKS; i++) {
- if (all || strcmp(k, lxchook_names[i]) == 0) {
+ if (all || strequal(k, lxchook_names[i])) {
lxc_list_for_each_safe (it, &c->hooks[i], next) {
lxc_list_del(it);
free(it->elem);
*p = '\0';
p++;
- if (strcmp(line, uname))
+ if (!strequal(line, uname))
continue;
p2 = strchr(p, ':');
*p = '\0';
p++;
- if (strcmp(line, uname))
+ if (!strequal(line, uname))
continue;
p2 = strchr(p, ':');
item->elem = it->elem;
cg = it->elem;
- if (strcmp(cg->subsystem, "memory.memsw.limit_in_bytes") == 0) {
+ if (strequal(cg->subsystem, "memory.memsw.limit_in_bytes")) {
/* Store the memsw_limit location */
memsw_limit = item;
- } else if (strcmp(cg->subsystem, "memory.limit_in_bytes") == 0 &&
+ } else if (strequal(cg->subsystem, "memory.limit_in_bytes") &&
memsw_limit != NULL) {
/* lxc.cgroup.memory.memsw.limit_in_bytes is found
* before lxc.cgroup.memory.limit_in_bytes, swap these