From: Andrew Morton <akpm@linux-foundation.org>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com,
torvalds@linux-foundation.org
Subject: Re: [PATCH] shm: Remove silly double assignment
Date: Wed, 11 Jun 2008 03:45:06 -0700 [thread overview]
Message-ID: <20080611034506.05ad07ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080610125338.GB3165@hmsreliant.think-freely.org>
On Tue, 10 Jun 2008 08:53:39 -0400 Neil Horman <nhorman@tuxdriver.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@tuxdriver.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.
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.
The compiler should optimise away the second assignment anyway.
next prev parent reply other threads:[~2008-06-11 10:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-10 12:53 [PATCH] shm: Remove silly double assignment Neil Horman
2008-06-11 10:45 ` Andrew Morton [this message]
2008-06-11 17:03 ` Neil Horman
2008-06-18 10:06 ` Ingo Molnar
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=20080611034506.05ad07ae.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nhorman@tuxdriver.com \
--cc=torvalds@linux-foundation.org \
/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