Re: [PATCH 06/68] 0 -> NULL, for arch/frv

From: Al Viro
Date: Fri Jul 27 2007 - 06:41:06 EST


On Fri, Jul 27, 2007 at 12:21:53PM +0200, Yoann Padioleau wrote:
> > On Fri, Jul 27, 2007 at 11:44:35AM +0200, Yoann Padioleau wrote:
> >> pte = pte_alloc_kernel(pme, va);
> >> - if (pte != 0) {
> >> + if (pte != NULL) {

> I don't understand. pte is a pointer right ? So why should we
> keep the == 0 ?

Idiomatic form for "has allocation succeeded?" is neither "if (p != 0)" nor
"if (p != NULL)". It's simply "if (p)".

Note that it depends upon context. For something that combines assignment
with test
if ((p = foo_alloc()) != NULL)
would be the right way to go. Ditto for
flag = (p == NULL)
(alternative would be "flag = !p", which is usually not nice or even
"flag = !!p" for the opposite test, and that's bloody atrocious).

For places like
- if (spu_disassemble_table[o] == 0)
+ if (spu_disassemble_table[o] == NULL)
spu_disassemble_table[o] = &spu_opcodes[i];
it's a matter of taste; there I'd go for explicit comparison with NULL.
I'd also go for explicit comparisons in places like
- wait_event(journal->j_wait_done_commit, journal->j_task == 0);
+ wait_event(journal->j_wait_done_commit, journal->j_task == NULL);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/