* [PATCH] SELinux: Do not assign the same value twice to the same variable
@ 2010-10-30 21:10 Jesper Juhl
2010-10-31 3:32 ` Eric Paris
0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2010-10-30 21:10 UTC (permalink / raw)
To: linux-kernel
Cc: Stephen Smalley, James Morris, Eric Paris, Stephen Hemminger,
ulia Lawall, linux-security-module
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.
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;
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] SELinux: Do not assign the same value twice to the same variable
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
2010-10-31 6:21 ` Jesper Juhl
0 siblings, 1 reply; 3+ messages in thread
From: Eric Paris @ 2010-10-31 3:32 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-kernel, Stephen Smalley, James Morris, Eric Paris,
Stephen Hemminger, ulia Lawall, linux-security-module
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;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] SELinux: Do not assign the same value twice to the same variable
2010-10-31 3:32 ` Eric Paris
@ 2010-10-31 6:21 ` Jesper Juhl
0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2010-10-31 6:21 UTC (permalink / raw)
To: Eric Paris
Cc: linux-kernel, Stephen Smalley, James Morris, Eric Paris,
Stephen Hemminger, ulia Lawall, linux-security-module
On Sat, 30 Oct 2010, Eric Paris wrote:
> 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?
>
It's not a problem as such, it just seemed a silly thing to do when I came
across it. But, I can see your point in leaving it, so just forget about
the patch.
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-31 6:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2010-10-31 6:21 ` Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox