nsjail: make njsconf::cgroup_pids_max unsigned int
authorRobert Swiecki <robert@swiecki.net>
Wed, 25 Oct 2017 13:50:24 +0000 (15:50 +0200)
committerRobert Swiecki <robert@swiecki.net>
Wed, 25 Oct 2017 13:50:24 +0000 (15:50 +0200)
cgroup.c
cmdline.c
nsjail.h

index 99fa007c3654dc88300c74fea597535bd449f627..9694308145cc6c0ffb59df349c1773eb1f1c5d0b 100644 (file)
--- a/cgroup.c
+++ b/cgroup.c
@@ -85,7 +85,7 @@ static bool cgroupInitNsFromParentMem(struct nsjconf_t* nsjconf, pid_t pid)
 
 static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
 {
-       if (nsjconf->cgroup_pids_max == (size_t)0) {
+       if (nsjconf->cgroup_pids_max == 0U) {
                return true;
        }
 
@@ -99,9 +99,9 @@ static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
        }
 
        char fname[PATH_MAX];
-       if (nsjconf->cgroup_pids_max != (size_t)0) {
+       if (nsjconf->cgroup_pids_max != 0U) {
                char pids_max_str[512];
-               snprintf(pids_max_str, sizeof(pids_max_str), "%zu", nsjconf->cgroup_pids_max);
+               snprintf(pids_max_str, sizeof(pids_max_str), "%u", nsjconf->cgroup_pids_max);
                snprintf(fname, sizeof(fname), "%s/pids.max", pids_cgroup_path);
                LOG_D("Setting '%s' to '%s'", fname, pids_max_str);
                if (!utilWriteBufToFile(
@@ -125,7 +125,7 @@ static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
 
 static bool cgroupInitNsFromParentNetCls(struct nsjconf_t* nsjconf, pid_t pid)
 {
-       if (nsjconf->cgroup_net_cls_classid == (unsigned int)0) {
+       if (nsjconf->cgroup_net_cls_classid == 0U) {
                return true;
        }
 
@@ -139,7 +139,7 @@ static bool cgroupInitNsFromParentNetCls(struct nsjconf_t* nsjconf, pid_t pid)
        }
 
        char fname[PATH_MAX];
-       if (nsjconf->cgroup_net_cls_classid != (unsigned int)0) {
+       if (nsjconf->cgroup_net_cls_classid != 0U) {
                char net_cls_classid_str[512];
                snprintf(net_cls_classid_str, sizeof(net_cls_classid_str), "0x%x",
                    nsjconf->cgroup_net_cls_classid);
@@ -195,7 +195,7 @@ void cgroupFinishFromParentMem(struct nsjconf_t* nsjconf, pid_t pid)
 
 void cgroupFinishFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
 {
-       if (nsjconf->cgroup_pids_max == (size_t)0) {
+       if (nsjconf->cgroup_pids_max == 0) {
                return;
        }
        char pids_cgroup_path[PATH_MAX];
index 7681ecc5f329830d65dc60a88a062f2329bd691c..a21f009ed599c03b7a339365796ad1182988e355 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -363,7 +363,7 @@ bool cmdlineParse(int argc, char* argv[], struct nsjconf_t* nsjconf)
                .cgroup_mem_max = (size_t)0,
                .cgroup_pids_mount = "/sys/fs/cgroup/pids",
                .cgroup_pids_parent = "NSJAIL",
-               .cgroup_pids_max = (size_t)0,
+               .cgroup_pids_max = (unsigned int)0,
                .cgroup_net_cls_mount = "/sys/fs/cgroup/net_cls",
                .cgroup_net_cls_parent = "NSJAIL",
                .cgroup_net_cls_classid = (unsigned int)0,
@@ -730,7 +730,7 @@ bool cmdlineParse(int argc, char* argv[], struct nsjconf_t* nsjconf)
                        nsjconf->cgroup_mem_parent = optarg;
                        break;
                case 0x811:
-                       nsjconf->cgroup_pids_max = (size_t)strtoull(optarg, NULL, 0);
+                       nsjconf->cgroup_pids_max = (unsigned int)strtoul(optarg, NULL, 0);
                        break;
                case 0x812:
                        nsjconf->cgroup_pids_mount = optarg;
index d9a8ad992e3580c730b0c33378c506539f4bb64a..6c3dd0e5f7aa7616f8253eefbd8883522e873b7f 100644 (file)
--- a/nsjail.h
+++ b/nsjail.h
@@ -157,7 +157,7 @@ struct nsjconf_t {
        size_t cgroup_mem_max;
        const char* cgroup_pids_mount;
        const char* cgroup_pids_parent;
-       size_t cgroup_pids_max;
+       unsigned int cgroup_pids_max;
        const char* cgroup_net_cls_mount;
        const char* cgroup_net_cls_parent;
        unsigned int cgroup_net_cls_classid;