lkml.org 
[lkml]   [2007]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/68] 0 -> NULL, for arch/frv
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-07-27 12:43    [W:0.056 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site