From: Ingo Molnar <mingo@elte.hu>
To: kernel-janitors@vger.kernel.org
Subject: Re: Fix sparse warning
Date: Fri, 23 Oct 2009 07:59:11 +0000 [thread overview]
Message-ID: <20091023075911.GC10067@elte.hu> (raw)
In-Reply-To: <4ADCD559.9080807@sysvalve.homelinux.net>
* "L. Alberto Giménez" <agimenez@sysvalve.homelinux.net> wrote:
> > - All such variables need proper locking, as they can be re-entered
> > from multiple CPUs (while local stack variables cannot and generally
> > dont need such locking). Moving them to file scope makes sure it's
> > all visible and makes sure proper locking is done.
>
> The same thing about visibility applies as above. Moreover, I can't
> see any explicit lock inside the main.c file. [...]
It's implicit - all bootup execution is serialized.
So it's double important to make any global state clearly visible -
should any of this be pushed to async bootup init functions (which would
require the addition of a lock).
> > All in one, there's a constant trend away from statics at function
> > scope. It can be done correctly but is subtly fragile for the above
> > reasons.
>
> Indeed it may be fragile. And I'm sure that you've faced tons of bugs
> because of declaring static variables in funcion scope and not having
> it in mind when using those variables. I'm just a newbie and I have
> not faced serious challenges about kernel development, but I think
> that those "sanity" things should be fixed (I'm kind of standards
> taliban :) ), but I need your expertise to know *how* to fix it, from
> the point of view of semantics and not just syntax.
I think it's subtly wrong if you try to 'fix a warning', as the subject
line already says it.
Warnings are not something that should be 'fixed' - they are just a sign
of some sort of trouble:
1- bug/limitation in the tool (Sparse)
2- uncleanliness in the source code
3- bug in the source code
here it seems to be case #1, as file scope statics are perfectly fine,
even if used by a single function.
Ingo
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-10-23 7:59 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
2009-10-21 11:37 ` Ingo Molnar
2009-10-21 21:18 `
2009-10-23 7:59 ` Ingo Molnar [this message]
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=20091023075911.GC10067@elte.hu \
--to=mingo@elte.hu \
--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.