LWN.net Logo

Removing NULL checks

Removing NULL checks

Posted Jul 17, 2009 22:39 UTC (Fri) by nix (subscriber, #2304)
In reply to: Removing NULL checks by stevenb
Parent article: Linux 2.6.30 exploit posted

It would be an excessive optimization, if it wasn't that GCC has a way to
turn it off... which the kernel is not using.


(Log in to post comments)

Removing NULL checks

Posted Jul 17, 2009 22:56 UTC (Fri) by mikov (subscriber, #33179) [Link]

I don't think that disabling this option for a kernel compile is reasonable. It is not reasonable to have to check every new optimization for every new version of a compiler, assuming the optimizations themselves are valid.

What is reasonable on the other hand is to know C and to write valid C code, which doesn't break when a butterfly flaps its wings. I still can't understand why everybody is making such a big deal over such a trivial bug. It is similar to relying on the value of "(a++) + (a++)" - basic C stuff that hopefully everybody knows by now.

If this was an user app nobody would think twice about it. So, what, the kernel is an excuse for sloppy coding?? I would hope that the opposite was true...

Removing NULL checks

Posted Jul 17, 2009 23:33 UTC (Fri) by stevenb (guest, #11536) [Link]

This optimization is not even new. It was added to GCC ten years ago, see
http://gcc.gnu.org/news/null.html

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