From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752776AbdEPSeD (ORCPT ); Tue, 16 May 2017 14:34:03 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34846 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752762AbdEPSck (ORCPT ); Tue, 16 May 2017 14:32:40 -0400 MIME-Version: 1.0 X-Originating-IP: [108.49.102.27] In-Reply-To: <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> References: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> From: Paul Moore Date: Tue, 16 May 2017 14:32:38 -0400 Message-ID: Subject: Re: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert() To: SF Markus Elfring Cc: Casey Schaufler , Eric Paris , James Morris , "Serge E. Hallyn" , Stephen Smalley , William Roberts , linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, LKML , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 4, 2017 at 7:14 AM, SF Markus Elfring wrote: > 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(-) Merged. > 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 > -- paul moore www.paul-moore.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Moore Date: Tue, 16 May 2017 18:32:38 +0000 Subject: Re: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert() Message-Id: List-Id: References: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> In-Reply-To: <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@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 On Tue, Apr 4, 2017 at 7:14 AM, SF Markus Elfring wrote: > 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(-) Merged. > 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 > -- paul moore www.paul-moore.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: paul@paul-moore.com (Paul Moore) Date: Tue, 16 May 2017 14:32:38 -0400 Subject: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert() In-Reply-To: <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> References: <5704e656-708a-b611-5611-70fc65dc67e8@users.sourceforge.net> <61cd20e9-211e-b974-3525-fcb5fdf8fa7e@users.sourceforge.net> Message-ID: To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On Tue, Apr 4, 2017 at 7:14 AM, SF Markus Elfring wrote: > 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(-) Merged. > 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 > -- paul moore www.paul-moore.com -- 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