lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080611170321.GA23507@hmsreliant.think-freely.org>
Date:	Wed, 11 Jun 2008 13:03:21 -0400
From:	Neil Horman <nhorman@...driver.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-kernel@...r.kernel.org, mingo@...hat.com,
	torvalds@...ux-foundation.org
Subject: Re: [PATCH] shm: Remove silly double assignment

On Wed, Jun 11, 2008 at 03:45:06AM -0700, Andrew Morton wrote:
> On Tue, 10 Jun 2008 08:53:39 -0400 Neil Horman <nhorman@...driver.com> wrote:
> 
> >     Found a silly double assignment of err is do_shmat.  Silly, but good to clean up
> >     the useless code.
> >     
> >     Signed-off-by: Neil Horman <nhorman@...driver.com>
> > 
> > diff --git a/ipc/shm.c b/ipc/shm.c
> > index 554429a..d05f6b5 100644
> > --- a/ipc/shm.c
> > +++ b/ipc/shm.c
> > @@ -894,8 +894,6 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
> >  	if (!sfd)
> >  		goto out_put_dentry;
> >  
> > -	err = -ENOMEM;
> > -
> >  	file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations);
> >  	if (!file)
> >  		goto out_free;
> 
> Not silly, really.  Look:
> 
> 	err = -ENOMEM;
> 	if (expr1)
> 		goto out;
> 
> 	err = -ENOMEM;
> 	if (expr2)
> 		goto out;
> 
> each of these two units is a separate, self-contained clause.  Removing
> the second assignment to `err' breaks that separation and will make one
> clause undesirably dependent upon the other.
yes, I see that keeping the second assignment lets you insert code in the middle
without having up to update afterwards.  I just don't think the redundant
assignment is worth keeping just for that purpose.


> 
> Example: if someone later comes up and does
> 
> 	err = -ENOMEM;
> 	if (expr1)
> 		goto out;
> 
> +	er = -EINVAL;
> +	if (expr3)
> +		goto out;
> 
> 	if (expr2)
> 		goto out;
> 
> then whoops, it broke.
> 
Yes, but that would be the fault of the subsequent patch, and if they couldn't
see that problem, I fear that a double assignment isn't going to help them much.

> The compiler should optimise away the second assignment anyway.
Agreed, its really not a big deal.  If its not worth it, its fine with me.  I
was just being janitorial, and thought this looked rather redundant.

Best
Neil

-- 
/****************************************************
 * Neil Horman <nhorman@...driver.com>
 * Software Engineer, Red Hat
 ****************************************************/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ