* comparison of safe pointers
@ 2007-05-25 13:07 Al Viro
2007-05-25 15:29 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2007-05-25 13:07 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-sparse
Why do we generate a warning when we compare two pointers
declared as safe? I understand why we do that when such beast gets
used as condition (i.e. implicitly compare with NULL), but what's
wrong with
int foo(void __safe *p, void __safe *q)
{
return p == q;
}
What did you want that check in evaluate_compare() to catch? Is that
about warning on explicit comparison with NULL?
Al, crawling through evaluate.c and fixing odd cases in typechecking...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: comparison of safe pointers
2007-05-25 13:07 comparison of safe pointers Al Viro
@ 2007-05-25 15:29 ` Linus Torvalds
2007-05-25 15:44 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2007-05-25 15:29 UTC (permalink / raw)
To: Al Viro; +Cc: linux-sparse
On Fri, 25 May 2007, Al Viro wrote:
>
> What did you want that check in evaluate_compare() to catch? Is that
> about warning on explicit comparison with NULL?
Yes. It was explicitly meant to be a "anybody who tests this pointer
missed the 'safe' part of it".
But I never used it, so it was really meant as a concept thing, and I
don't think it's wrong to test against non-null.
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: comparison of safe pointers
2007-05-25 15:29 ` Linus Torvalds
@ 2007-05-25 15:44 ` Al Viro
0 siblings, 0 replies; 3+ messages in thread
From: Al Viro @ 2007-05-25 15:44 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-sparse
On Fri, May 25, 2007 at 08:29:11AM -0700, Linus Torvalds wrote:
>
>
> On Fri, 25 May 2007, Al Viro wrote:
> >
> > What did you want that check in evaluate_compare() to catch? Is that
> > about warning on explicit comparison with NULL?
>
> Yes. It was explicitly meant to be a "anybody who tests this pointer
> missed the 'safe' part of it".
>
> But I never used it, so it was really meant as a concept thing, and I
> don't think it's wrong to test against non-null.
OK... Pointer comparisons care about null pointer constants anyway
(BTW, ordered comparison with NULL should give a warning - it's not
a valid C and it makes no sense whatsoever even as an extension),
so that's not a problem.
Other places that care are ?:, simple assignment when target is a pointer,
passing arguments to function with prototype when parameter type is a pointer
(same logics as with assignment) and cast adding address space (valid for
NULL, not valid for random void *).
AFAICS, that covers everything; definitely all contexts where null pointer
constants are recognized by C and I think that it covers all places where
they matter for sparse extensions...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-25 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-25 13:07 comparison of safe pointers Al Viro
2007-05-25 15:29 ` Linus Torvalds
2007-05-25 15:44 ` Al Viro
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).