devcgroup: code cleanup
PATCH 1/1 devcgroup: code cleanup
- remove a redundant memset()
- use simple_strtoul() to parse major/minor
Signed-off-by Li Zefan <[email protected]>
--- security/device_cgroup.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-)
security/device_cgroup.c +3 -12
@@ -188,7 +188,7 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss, } wh->minor = wh->major = ~0 ; wh->type =DEV_ALL ; - wh->access =ACC_MKNOD |ACC_READ |ACC_WRITE ; + wh->access =ACC_MASK ;list_add (&wh->list, &dev_cgroup->whitelist); }else { parent_dev_cgroup =cgroup_to_devcgroup (parent_cgroup);
@@ -250,7 +250,6 @@ static char type_to_char(short type)static void set_majmin (char *str,unsigned m) { -memset (str,0 ,MAJMINLEN );if (m == ~0 )sprintf (str,"*" );else
@@ -405,11 +404,7 @@ static ssize_t devcgroup_access_write(struct cgroup *cgroup, struct cftype *cft, wh.major = ~0 ; b++; }else if (isdigit (*b)) { - wh.major =0 ; -while (isdigit (*b)) { - wh.major = wh.major*10 +(*b-'0' ); - b++; - } + wh.major =simple_strtoul (b, &b,0 ); }else { retval = -EINVAL ; goto out2;
@@ -425,11 +420,7 @@ static ssize_t devcgroup_access_write(struct cgroup *cgroup, struct cftype *cft, wh.minor = ~0 ; b++; }else if (isdigit (*b)) { - wh.minor =0 ; -while (isdigit (*b)) { - wh.minor = wh.minor*10 +(*b-'0' ); - b++; - } + wh.minor =simple_strtoul (b, &b,0 ); }else { retval = -EINVAL ; goto out2;
Signature · 1 line
1.5.4.rc3
Quoted 4 lines · Li Zefan
- remove a redundant
memset()
- usesimple_strtoul()to parse major/minorSigned-off-by Li Zefan <[email protected]>
Thanks, all look good.
Acked-by Serge Hallyn <[email protected]>
thanks
-serge
Quoted 53 lines
--- security/device_cgroup.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-)security/device_cgroup.c +3
-12@@ -188,7 +188,7 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss, } wh->minor = wh->major = ~0 ; wh->type =DEV_ALL ; - wh->access =ACC_MKNOD |ACC_READ |ACC_WRITE ; + wh->access =ACC_MASK ;list_add (&wh->list, &dev_cgroup->whitelist); }else { parent_dev_cgroup =cgroup_to_devcgroup (parent_cgroup);@@ -250,7 +250,6 @@ static char type_to_char(short type)static void set_majmin (char *str,unsigned m) { -memset (str,0 ,MAJMINLEN );if (m == ~0 )sprintf (str,"*" );else @@ -405,11 +404,7 @@ static ssize_t devcgroup_access_write(struct cgroup *cgroup, struct cftype *cft, wh.major = ~0 ; b++; }else if (isdigit (*b)) { - wh.major =0 ; -while (isdigit (*b)) { - wh.major = wh.major*10 +(*b-'0' ); - b++; - } + wh.major =simple_strtoul (b, &b,0 ); }else { retval = -EINVAL ; goto out2;@@ -425,11 +420,7 @@ static ssize_t devcgroup_access_write(struct cgroup *cgroup, struct cftype *cft, wh.minor = ~0 ; b++; }else if (isdigit (*b)) { - wh.minor =0 ; -while (isdigit (*b)) { - wh.minor = wh.minor*10 +(*b-'0' ); - b++; - } + wh.minor =simple_strtoul (b, &b,0 ); }else { retval = -EINVAL ; goto out2;Signature · 1 line
1.5.4.rc3