From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757942AbYGHBxd (ORCPT ); Mon, 7 Jul 2008 21:53:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755716AbYGHBwv (ORCPT ); Mon, 7 Jul 2008 21:52:51 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:61253 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755470AbYGHBwu (ORCPT ); Mon, 7 Jul 2008 21:52:50 -0400 Message-ID: <4872C811.8060608@cn.fujitsu.com> Date: Tue, 08 Jul 2008 09:51:13 +0800 From: Li Zefan User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Andrew Morton CC: LKML , "Serge E. Hallyn" , Paul Menage , Pavel Emelianov Subject: [PATCH 3/3] devcgroup: code cleanup Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - clean up set_majmin() - use simple_strtoul() to parse major/minor Signed-off-by: Li Zefan Acked-by: Serge Hallyn --- security/device_cgroup.c | 19 +++++-------------- 1 files changed, 5 insertions(+), 14 deletions(-) diff --git a/security/device_cgroup.c b/security/device_cgroup.c index ddd92ce..34a10bf 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -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,11 +250,10 @@ static char type_to_char(short type) static void set_majmin(char *str, unsigned m) { - memset(str, 0, MAJMINLEN); if (m == ~0) - sprintf(str, "*"); + strcpy(str, "*"); else - snprintf(str, MAJMINLEN, "%u", m); + sprintf(str, "%u", m); } static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft, @@ -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; -- 1.5.4.rc3