LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: WANG Cong <xiyou.wangcong@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [Patch] Fix shadowed variables in fs/binfmt_elf.c
Date: Sat, 16 Feb 2008 16:50:24 +0800 (CST) [thread overview]
Message-ID: <20080216.165024.199372966.xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <20080215123459.0a675826.akpm@linux-foundation.org>
From: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Patch] Fix shadowed variables in fs/binfmt_elf.c
Date: Fri, 15 Feb 2008 12:34:59 -0800
Message-ID: <20080215123459.0a675826.akpm@linux-foundation.org>
> On Fri, 15 Feb 2008 21:58:02 +0800 (CST)
> WANG Cong <xiyou.wangcong@gmail.com> wrote:
>
> >
> > Fix these sparse warings:
> > fs/binfmt_elf.c:1749:29: warning: symbol 'tmp' shadows an earlier one
> > fs/binfmt_elf.c:1734:28: originally declared here
> > fs/binfmt_elf.c:2009:26: warning: symbol 'vma' shadows an earlier one
> > fs/binfmt_elf.c:1892:24: originally declared here
> >
> > Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
> >
> > ---
> > diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> > index 41a958a..6562563 100644
> > --- a/fs/binfmt_elf.c
> > +++ b/fs/binfmt_elf.c
> > @@ -1746,11 +1746,11 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
> > while_each_thread(g, p);
> > rcu_read_unlock();
> > list_for_each(t, &info->thread_list) {
> > - struct elf_thread_status *tmp;
> > + struct elf_thread_status *temp;
> > int sz;
> >
> > - tmp = list_entry(t, struct elf_thread_status, list);
> > - sz = elf_dump_thread_status(signr, tmp);
> > + temp = list_entry(t, struct elf_thread_status, list);
> > + sz = elf_dump_thread_status(signr, temp);
> > info->thread_status_size += sz;
> > }
> > }
>
> `tmp' is an awful identifier, and renaming it to "temp" hardly improves it.
> Please take any opportunity to fix this sort of thing.
>
> I chose "ets" which is a bit weird but once one understand what it means,
> it makes the code much easier to follow.
>
> Also used the same local for both loops. There seems little point in
> instantiating a second one.
I agree. The first 'tmp' you showed is really not good, 'ets' is better.
Thanks, Andrew!
prev parent reply other threads:[~2008-02-16 8:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-15 13:58 WANG Cong
2008-02-15 20:34 ` Andrew Morton
2008-02-16 8:50 ` WANG Cong [this message]
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=20080216.165024.199372966.xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [Patch] Fix shadowed variables in fs/binfmt_elf.c' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).