lkml.org 
[lkml]   [2005]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 0/12] FS-Cache: Generic filesystem caching facility


On Tue, 15 Nov 2005, David Howells wrote:
>
> I don't think I have a need for both. Either I give you a cookie (for which
> there may be nothing in the cache); or I give you the "negative" cookie for
> which there's definitely nothing in the cache, and gracefully refuse to
> service it.
>
> So, would you still rather I used NULL? If so, I can change it easily enough.

Yes, if you don't have real negative cookies, then just use NULL.

Think of malloc(). It doesn't return MALLOC_OUT_OF_MEMORY_COOKIE when it
won't give you any more memory. It returns NULL.

The advantage of NULL is that people know what it is, and that the C
language _defines_ that you can do "if (xyzzy)" to test for non-NULL.
Conversely, the disadvantage of using a special cookie (that just happens
to be NULL) is that the test for NULL still _works_, so now you have two
ways of doing something and the compiler will never warn.

So in a very real sense, NULL _always_ exists. You can't make it go away
by defining it to another name, and by using another name you just confuse
things (if they are in fact the same).

Linus
-
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: 2009-11-18 23:46    [W:0.171 / U:1.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site