From: Matthew Wilcox <matthew@wil.cx>
To: kernel-janitors@vger.kernel.org
Subject: Re: Fix sparse warning
Date: Tue, 20 Oct 2009 22:24:41 +0000 [thread overview]
Message-ID: <20091020222440.GA9693@parisc-linux.org> (raw)
In-Reply-To: <4ADCD559.9080807@sysvalve.homelinux.net>
On Wed, Oct 21, 2009 at 12:02:17AM +0200, "L. Alberto Gim?nez" wrote:
> Matthew Wilcox wrote:
> > On Mon, Oct 19, 2009 at 11:08:41PM +0200, "L. Alberto Gim??nez" wrote:
>
> > 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, Walter, thanks for your reply.
>
> The static (file-scope) variable was introduced by Ingo Molnar in commit
> 4a683bf9.
>
> It seems that originally those three static variables were local
> variables, what turned out to cause a stack overflow. So, I think they
> will stay just like they are right now :) (thank god we have git-blame).
>
> Instead, I'll try to work on renaming the "offending" local variables
> and cleaning file by file sparse warnings.
Ah, you're conflating two things here (and this is a subtle corner of C,
but it's very important to understand the distinction. I'm not quite
sure why Ingo got it wrong ;-)
Here's the current situation:
static struct boot_trace_call call;
int do_one_initcall(initcall_t fn)
{
...
}
That allocates 'call' in the data segment, and gives it file scope.
You thought I meant this:
int do_one_initcall(initcall_t fn)
{
struct boot_trace_call call;
...
}
That would change the scope to be function-local, and allocate 'call'
on the stack.
What I actually meant was this:
int do_one_initcall(initcall_t fn)
{
static struct boot_trace_call call;
...
}
That makes the scope function-local, but allocates 'call' from the data
segment, not on the stack.
--
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 22:24 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
2009-10-20 7:24 ` walter harms
2009-10-20 22:02 `
2009-10-20 22:08 `
2009-10-20 22:24 ` Matthew Wilcox [this message]
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=20091020222440.GA9693@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.