comparison of safe pointers
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...
Quoted 3 lines · Al Viro
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
Quoted 4 lines · Linus Torvalds
Quoted 1 line · Al Viro
Quoted 8 lines
Quoted 2 lines
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...