From: Matthew Wilcox <matthew@wil.cx>
To: kernel-janitors@vger.kernel.org
Subject: Re: Fix sparse warning
Date: Tue, 20 Oct 2009 06:48:45 +0000 [thread overview]
Message-ID: <20091020064845.GI29158@parisc-linux.org> (raw)
In-Reply-To: <4ADCD559.9080807@sysvalve.homelinux.net>
On Mon, Oct 19, 2009 at 11:08:41PM +0200, "L. Alberto Gim??nez" wrote:
> I'm starting to do some cleanup for the project, and I'd like to begin
> fixing sparse errors.
Fixing sparse errors is a worthy place to start; it's certainly more
useful than doing checkpatch warning fixes.
> By the way, at first glance, it seems that the warnings that sparse
> catches may need some depth look (i.e. not a newbiew) not to mess things.
There's certainly a matter of style and taste when deciding how to fix
a warning ... if it were automatable, we could automate the fixes ;-)
> For example, my first compilation sparse checking throws this:
>
> init/main.c:763:13: warning: symbol 'call' shadows an earlier one
> init/main.c:710:31: originally declared here
> init/main.c:793:13: warning: symbol 'call' shadows an earlier one
> init/main.c:710:31: originally declared here
>
> If you take a look at the code, the global "call" variable is defined as:
>
> static struct boot_trace_call call;
>
> And what makes sparse whine is a local variable definition, totally
> unrelated (i think):
>
> static void __init do_initcalls(void)
> {
> initcall_t *call;
>
> for (call = __early_initcall_end; call < __initcall_end; call++)
> do_one_initcall(*call);
>
> /* Make sure there is no pending stuff from the initcall sequence */
> flush_scheduled_work();
> }
>
> So, it seems that I could "fix" this by changing the local variable
> name. The question is: is this _really_ needed apart from "code
> hygiene"? Should I "fix" (if you agree to call that "to fix") that issue?
It can certainly be confusing to have two variables with the same name.
Since gcc can do this, I'm not sure why we don't enable -Wshadow.
I think in this particular case, there's no reason for 'boot_trace_call'
to have file-level scope. I would move it inside the do_one_initcall()
function (and I'd do the same with msgbuf and boot_trace_ret too).
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2009-10-20 6:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-19 21:08 Fix sparse warning
2009-10-19 21:35 `
2009-10-20 6:48 ` Matthew Wilcox [this message]
2009-10-20 7:24 ` walter harms
2009-10-20 22:02 `
2009-10-20 22:08 `
2009-10-20 22:24 ` Matthew Wilcox
2009-10-21 11:37 ` Ingo Molnar
2009-10-21 21:18 `
2009-10-23 7:59 ` Ingo Molnar
2009-10-23 11:14 ` Matthew Wilcox
2009-10-23 11:38 ` Ingo Molnar
2009-10-23 11:51 ` Matthew Wilcox
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=20091020064845.GI29158@parisc-linux.org \
--to=matthew@wil.cx \
--cc=kernel-janitors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.