> Well, we'd have to start by fixing up the janitors that run around
> taking out the if statements in the callers. :)
You just need to document those two as special. Probably the
simplest is to tell the programmer and the compiler in one
fell swoop:
if (unlikely(p))
kfree(p);
Or that could be wrapped up in a macro:
#define kfree_likely_null(p) if (unlikely(p)) kfree(p)
Or just mention it to the programmer. A few possible one-line comments:
/* Testing before calling is faster if often NULL, as here. */
/* It's worth the (redundant) test for NULL if it often succeeds */
/* This test saves the call often enough to be worth it. */
/* Test for NULL not necessary, but worth it here */
/* Don't delete NULL test; speed trumps code size here */
/* Very often NULL, so avoid call overhead if possible */
/* kfree(NULL) is legal, but probabilities favor testing here */
-
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]