Fun with NULL pointers, part 2
Fun with NULL pointers, part 2
Posted Jul 21, 2009 21:50 UTC (Tue) by ebiederm (subscriber, #35028)In reply to: Fun with NULL pointers, part 2 by spender
Parent article: Fun with NULL pointers, part 2
No. BUG_ON(ptr == NULL) is generally a bad idea because it is fixing
a problem in the wrong place. Leading to maintenance problems etc.
a problem in the wrong place. Leading to maintenance problems etc.
In some common places like sysfs where the are a lot of users and mistakes are common because of the volume of use of the interface it makes sense.
In general it is better to simply make it impossible for a NULL pointer
to reach someplace. Or to handle that NULL pointer dereference.
Checking for the impossible just makes the code harder to understand.