The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, Stephen Smalley <sds@tycho.nsa.gov>,
	James Morris <jmorris@namei.org>,
	Eric Paris <eparis@parisplace.org>,
	Stephen Hemminger <shemminger@vyatta.com>,
	ulia Lawall <julia@diku.dk>,
	linux-security-module@vger.kernel.org
Subject: Re: [PATCH] SELinux: Do not assign the same value twice to the same variable
Date: Sat, 30 Oct 2010 23:32:44 -0400	[thread overview]
Message-ID: <1288495964.3017.37.camel@localhost.localdomain> (raw)
In-Reply-To: <alpine.LNX.2.00.1010302306230.1572@swampdragon.chaosbits.net>

On Sat, 2010-10-30 at 23:10 +0200, Jesper Juhl wrote:
> Hi,
> 
> It makes little sense to assign the same value to the same variable twice 
> when there is no code inbetween which could have changed the value of that 
> variable.

I don't like the patch.  The compiler will optimize it away (actually it
will optimize both of them away) and it make it clear that if a new
block is added in the middle that error codes can't be wrong....

It's just a personal preference I guess, but I like always setting the
error code before goto outs.  Is there a reason doing this is a problem?

-Eric
> 
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> Untested patch below.
> 
>  policydb.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index 94f630d..e5a30ff 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -1866,7 +1866,6 @@ static int genfs_read(struct policydb *p, void *fp)
>  			if (!newc)
>  				goto out;
>  
> -			rc = -ENOMEM;
>  			newc->u.name = kmalloc(len + 1, GFP_KERNEL);
>  			if (!newc->u.name)
>  				goto out;
> 
> 



  reply	other threads:[~2010-10-31  3:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-30 21:10 [PATCH] SELinux: Do not assign the same value twice to the same variable Jesper Juhl
2010-10-31  3:32 ` Eric Paris [this message]
2010-10-31  6:21   ` Jesper Juhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288495964.3017.37.camel@localhost.localdomain \
    --to=eparis@redhat.com \
    --cc=eparis@parisplace.org \
    --cc=jj@chaosbits.net \
    --cc=jmorris@namei.org \
    --cc=julia@diku.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox