LWN.net Logo

The thorny case of kmalloc(0)

The thorny case of kmalloc(0)

Posted Jun 8, 2007 16:05 UTC (Fri) by giraffedata (subscriber, #1954)
In reply to: The thorny case of kmalloc(0) by pj
Parent article: The thorny case of kmalloc(0)

the ASSERT only happens when ...

Grrr. The ASSERT always "happens" -- it's right there in unconditional code. The assertion fails only when ...

And really, it shouldn't even be discussed. If you're asserting that the pointer is not null, that means you're assuming for simplicity that the the allocation didn't fail and if you discuss the possibility that it did fail, you've defeated the purpose of the assertion. This code should probaby be instead an explicit test of the pointer for NULL.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds