linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Feature request - allow boolean operations of undefined cpp symbols
@ 2007-02-02 17:37 Pavel Roskin
  2007-02-02 18:25 ` Linus Torvalds
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Roskin @ 2007-02-02 17:37 UTC (permalink / raw)
  To: linux-sparse

Hello!

I think sparse should distinguish between safe and unsafe preprocessor
operations on undefined symbols.

For instance, "#if SYMBOL" has a very specific meaning, namely in
enables the subsequent code is SYMBOL is defined and not equal 0.
Implementing this in a "sparse friendly way" would be "#if
defined(SYMBOL) && SYMBOL", which is longer and more prone to errors
(the same symbol is used once, and nobody will warn in the first
instance is mistyped).

Some projects use configuration files with entries like "#define FEATURE
1".  Some users will replace "1" with "0", some users will comment it
out.  Supporting both requires "#if FEATURE", as opposed to "#ifdef
FEATURE", or somebody will be bitterly surprised that his or her edits
had no effect.

On the other hand, "#if FOO > BAR" is highly suspicious if FOO is
undefined.  Maybe sparse could allow boolean (and only boolean)
operations on undefined cpp symbols?

Unlike Linux kernel, the cases of "#if SYMBOL" with undefined SYMBOL
exist in glibc and other system libraries.  Relaxing sparse check would
make sparse more useful for checking other software.

-- 
Regards,
Pavel Roskin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-04-20 22:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-02 17:37 Feature request - allow boolean operations of undefined cpp symbols Pavel Roskin
2007-02-02 18:25 ` Linus Torvalds
2007-02-02 21:56   ` Christopher Li
2007-02-02 22:30     ` Pavel Roskin
2007-02-02 22:10       ` Christopher Li
2007-02-02 22:58         ` Pavel Roskin
2007-02-02 22:45     ` Linus Torvalds
2007-04-20 10:02   ` Josh Triplett
2007-04-20 22:42     ` Pavel Roskin

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).