From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753783AbdDDLQU (ORCPT ); Tue, 4 Apr 2017 07:16:20 -0400 Received: from mout.web.de ([217.72.192.78]:61850 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753827AbdDDLOu (ORCPT ); Tue, 4 Apr 2017 07:14:50 -0400 Subject: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert() From: SF Markus Elfring To: Casey Schaufler , Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts , linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov Cc: LKML , kernel-janitors@vger.kernel.org References: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> Message-ID: <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> Date: Tue, 4 Apr 2017 13:14:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:d6hBxYdqGFTxMdt64UPDXQ568x0U+0A8ta3bgVw1Tm+TrGkPhPE MKbJ2WI2aDgUj/Z9Ju2RT5U6BKaIKIZSGWLYPOOB60adsZU12Gva727/MTijshmBemSa+3U LLOadaE/dLNSvN6aw9zOWfuGrZL0Ru2DS5oGEkdv6udzDRZNngF5wmnrRYVaD74WvqENhJN UAYvOlpHOg5WT28UXzIxQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:KoKMeW1pshQ=:4INxQRCrQpomVVBTM4iKcR aKLkceXO453ovjKUTZsURXhm5ugdGzXk8pr3w4cGo4aihYp5Krnvc81lDCPOsllthn8Upbilc kwKVGjYYUwy/kWAVaeIusxQWy+IhWWIcCXfXSIqCXWU8PPk3TDe+NgnnvVH/dZV4VYm1yZAcS qD63HXfdHV+bseLWOdOxJADLNzRU499HCMZMONJj364yQn0JyuldyDA1X48CBTzZ7aDkkxWof kVjKhwUTnxnyV+9k+YujMYMBHY755RNndGo515x4Wwxq5VipyL41leIKGHew0pKrn4Mfh9eZl t/h2e4YIoBSzZ06gFJm9No0gQW35KQfvil4gtgRfMWcHgJiyIyyCYa0Mb34sPHEWbsIRTmc93 lrKe3Ne1MNeiZWVukWZiZJN3jVIb84DYB/pE+QZ1zlQ07cmvcGpI6c1zLRtGJVHljzOhCbFeJ BGWTWWEshpTHfFSRNtXoLXqQ0HfCJFT3UiICQxJlQ2D4fF+ou5tq6hzTve3o5CupvXsUi/uKA VBCTnGi+/rCsmY63tsDAdK+oDbrWamT/L2kGJsYXwu+2tai1cgFbcZ8CH1UR0piTwQWvvU300 l4PpZ2bassq0C7dZ52ZlPFyXty7LKF5b4JGPu2UStxjd2DUYDgopqV25efA15LOQ6LSei5UhK l7w7+FF9KpVc0HLHcfXOUjzMHmrHj2FMWYN8gMUa8qKC3hEKW7Hn3UOwsSFT9iHxCFgBhZBQ/ 0T2A7nglzB81cNJlKhki6zmh6ynhuZGNxcbMCReOFgibTBwrMT21B2F1BY7fDNWrBKTeWTilF 1q5uw8U Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Tue, 4 Apr 2017 11:33:53 +0200 * Return an error code without storing it in an intermediate variable. * Delete the local variable "rc" and the jump label "out" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index f6915f257486..c5f436b15d19 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s) int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) { - int hvalue, rc = 0; + int hvalue; struct sidtab_node *prev, *cur, *newnode; - if (!s) { - rc = -ENOMEM; - goto out; - } + if (!s) + return -ENOMEM; hvalue = SIDTAB_HASH(sid); prev = NULL; @@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) cur = cur->next; } - if (cur && sid == cur->sid) { - rc = -EEXIST; - goto out; - } + if (cur && sid == cur->sid) + return -EEXIST; newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (!newnode) { - rc = -ENOMEM; - goto out; - } + if (!newnode) + return -ENOMEM; + newnode->sid = sid; if (context_cpy(&newnode->context, context)) { kfree(newnode); - rc = -ENOMEM; - goto out; + return -ENOMEM; } if (prev) { @@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) s->nel++; if (sid >= s->next_sid) s->next_sid = sid + 1; -out: - return rc; + return 0; } static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) -- 2.12.2 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Tue, 04 Apr 2017 11:14:32 +0000 Subject: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert() Message-Id: <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> List-Id: References: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> In-Reply-To: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-security-module@vger.kernel.org From: Markus Elfring Date: Tue, 4 Apr 2017 11:33:53 +0200 * Return an error code without storing it in an intermediate variable. * Delete the local variable "rc" and the jump label "out" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index f6915f257486..c5f436b15d19 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s) int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) { - int hvalue, rc = 0; + int hvalue; struct sidtab_node *prev, *cur, *newnode; - if (!s) { - rc = -ENOMEM; - goto out; - } + if (!s) + return -ENOMEM; hvalue = SIDTAB_HASH(sid); prev = NULL; @@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) cur = cur->next; } - if (cur && sid = cur->sid) { - rc = -EEXIST; - goto out; - } + if (cur && sid = cur->sid) + return -EEXIST; newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (!newnode) { - rc = -ENOMEM; - goto out; - } + if (!newnode) + return -ENOMEM; + newnode->sid = sid; if (context_cpy(&newnode->context, context)) { kfree(newnode); - rc = -ENOMEM; - goto out; + return -ENOMEM; } if (prev) { @@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) s->nel++; if (sid >= s->next_sid) s->next_sid = sid + 1; -out: - return rc; + return 0; } static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) -- 2.12.2 From mboxrd@z Thu Jan 1 00:00:00 1970 From: elfring@users.sourceforge.net (SF Markus Elfring) Date: Tue, 4 Apr 2017 13:14:32 +0200 Subject: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert() In-Reply-To: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> References: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> Message-ID: <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org From: Markus Elfring Date: Tue, 4 Apr 2017 11:33:53 +0200 * Return an error code without storing it in an intermediate variable. * Delete the local variable "rc" and the jump label "out" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index f6915f257486..c5f436b15d19 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s) int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) { - int hvalue, rc = 0; + int hvalue; struct sidtab_node *prev, *cur, *newnode; - if (!s) { - rc = -ENOMEM; - goto out; - } + if (!s) + return -ENOMEM; hvalue = SIDTAB_HASH(sid); prev = NULL; @@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) cur = cur->next; } - if (cur && sid == cur->sid) { - rc = -EEXIST; - goto out; - } + if (cur && sid == cur->sid) + return -EEXIST; newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (!newnode) { - rc = -ENOMEM; - goto out; - } + if (!newnode) + return -ENOMEM; + newnode->sid = sid; if (context_cpy(&newnode->context, context)) { kfree(newnode); - rc = -ENOMEM; - goto out; + return -ENOMEM; } if (prev) { @@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) s->nel++; if (sid >= s->next_sid) s->next_sid = sid + 1; -out: - return rc; + return 0; } static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) -- 2.12.2 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html