linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Paul Mundt <lethal@linux-sh.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Nick Piggin <npiggin@suse.de>,
	Linux Memory Management <linux-mm@kvack.org>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
	Hugh Dickins <hugh@tiscali.co.uk>, ralf <ralf@linux-mips.org>
Subject: Re: [RFC/PATCH] mm: Pass virtual address to [__]p{te,ud,md}_free_tlb()
Date: Mon, 27 Jul 2009 17:41:38 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0907271727220.3186@localhost.localdomain> (raw)
In-Reply-To: <20090728002529.GB22668@linux-sh.org>



On Tue, 28 Jul 2009, Paul Mundt wrote:
>
> Yup, that seems to be what happened. I've never seen a warning about this
> with any compiler version, otherwise we would have caught this much
> earlier. As soon as the addr -> a rename took place it blew up
> immediately as a redefinition. Is there a magical gcc flag we can turn on
> to warn on identical definitions, even if just for testing?

No, this is actually defined C behavior - identical macro redefinitions 
are ok. That's very much on purpose, and allows different header files to 
use an identical #define to define some common macro.

Strictly speaking, this is a "safety feature", in that you obviously 
_could_ just always do a #undef+#define, but such a case would be able to 
redefine a macro even if the new definition didn't match the old one. So 
the C pre-processor rules is that you can safely re-define something if 
you re-define it identically.

Of course, we could make the rules for the kernel be stricter, but I don't 
know if there are any flags to warn about it, since it's such a standard C 
feature: the lack of warning is _not_ an accident.

It would be trivial to teach sparse to warn about it, of course. Look at 
sparse/pre-process.c, function do_handle_define(). Notice how it literally 
checks that any previous #define is identical in both expansion and 
argument list, with:

		if (token_list_different(sym->expansion, expansion) ||
		    token_list_different(sym->arglist, arglist)) {

and just make token_list_different() always return true (this is the only 
use of that function).

I haven't checked if such a change would actually result in a lot of 
warnings.

		Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Paul Mundt <lethal@linux-sh.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Nick Piggin <npiggin@suse.de>,
	Linux Memory Management <linux-mm@kvack.org>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
	Hugh Dickins <hugh@tiscali.co.uk>, ralf <ralf@linux-mips.org>
Subject: Re: [RFC/PATCH] mm: Pass virtual address to [__]p{te,ud,md}_free_tlb()
Date: Mon, 27 Jul 2009 17:41:38 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0907271727220.3186@localhost.localdomain> (raw)
Message-ID: <20090728004138.WFZKIIKfaekRIOvpQvRYA-cQ6iwr56gk0iex0TvGjBc@z> (raw)
In-Reply-To: <20090728002529.GB22668@linux-sh.org>



On Tue, 28 Jul 2009, Paul Mundt wrote:
>
> Yup, that seems to be what happened. I've never seen a warning about this
> with any compiler version, otherwise we would have caught this much
> earlier. As soon as the addr -> a rename took place it blew up
> immediately as a redefinition. Is there a magical gcc flag we can turn on
> to warn on identical definitions, even if just for testing?

No, this is actually defined C behavior - identical macro redefinitions 
are ok. That's very much on purpose, and allows different header files to 
use an identical #define to define some common macro.

Strictly speaking, this is a "safety feature", in that you obviously 
_could_ just always do a #undef+#define, but such a case would be able to 
redefine a macro even if the new definition didn't match the old one. So 
the C pre-processor rules is that you can safely re-define something if 
you re-define it identically.

Of course, we could make the rules for the kernel be stricter, but I don't 
know if there are any flags to warn about it, since it's such a standard C 
feature: the lack of warning is _not_ an accident.

It would be trivial to teach sparse to warn about it, of course. Look at 
sparse/pre-process.c, function do_handle_define(). Notice how it literally 
checks that any previous #define is identical in both expansion and 
argument list, with:

		if (token_list_different(sym->expansion, expansion) ||
		    token_list_different(sym->arglist, arglist)) {

and just make token_list_different() always return true (this is the only 
use of that function).

I haven't checked if such a change would actually result in a lot of 
warnings.

		Linus

  reply	other threads:[~2009-07-28  0:41 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-15  7:49 [RFC/PATCH] mm: Pass virtual address to [__]p{te,ud,md}_free_tlb() Benjamin Herrenschmidt
2009-07-15 13:56 ` [RFC/PATCH] mm: Pass virtual address to [__]p{te, ud, md}_free_tlb() Nick Piggin
2009-07-15 13:56   ` [RFC/PATCH] mm: Pass virtual address to [__]p{te,ud,md}_free_tlb() Nick Piggin
2009-07-16  1:54   ` Benjamin Herrenschmidt
2009-07-16  1:54     ` Benjamin Herrenschmidt
2009-07-20  8:10     ` Nick Piggin
2009-07-20 10:00       ` Benjamin Herrenschmidt
2009-07-20 10:00         ` Benjamin Herrenschmidt
2009-07-20 10:38         ` Nick Piggin
2009-07-21  0:02           ` Benjamin Herrenschmidt
2009-07-21  0:02             ` Benjamin Herrenschmidt
2009-07-21  7:05             ` Nick Piggin
2009-07-20  7:11   ` Benjamin Herrenschmidt
2009-07-20  7:11     ` Benjamin Herrenschmidt
2009-07-20  7:48     ` Martin Schwidefsky
2009-07-20  7:48       ` Martin Schwidefsky
2009-07-20  8:05     ` Nick Piggin
2009-07-20  8:05       ` Nick Piggin
2009-07-20  9:59       ` Benjamin Herrenschmidt
2009-07-20  9:59         ` Benjamin Herrenschmidt
2009-07-20 10:39         ` Nick Piggin
2009-07-22 16:31     ` Linus Torvalds
2009-07-23  0:53       ` Benjamin Herrenschmidt
2009-07-23  0:59         ` Kumar Gala
2009-07-27 19:11         ` Linus Torvalds
2009-07-27 19:11           ` Linus Torvalds
2009-07-27 21:35           ` Benjamin Herrenschmidt
2009-07-27 21:35             ` Benjamin Herrenschmidt
2009-07-28  0:17           ` Benjamin Herrenschmidt
2009-07-28  0:17             ` Benjamin Herrenschmidt
2009-07-28  0:25             ` Paul Mundt
2009-07-28  0:41               ` Linus Torvalds [this message]
2009-07-28  0:41                 ` Linus Torvalds
2009-07-16  1:36 ` Michael Ellerman
2009-07-16  1:56   ` Benjamin Herrenschmidt
2009-07-16  1:56     ` Benjamin Herrenschmidt
2009-07-20 12:46 ` David Howells
2009-07-20 12:46   ` David Howells

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=alpine.LFD.2.01.0907271727220.3186@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=hugh@tiscali.co.uk \
    --cc=lethal@linux-sh.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=npiggin@suse.de \
    --cc=ralf@linux-mips.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 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).