Re: [PATCH 0/12] FS-Cache: Generic filesystem caching facility

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux