User: Password:
Subscribe / Log in / New account

Fun with NULL pointers, part 1

Fun with NULL pointers, part 1

Posted Jul 20, 2009 23:39 UTC (Mon) by ncm (subscriber, #165)
In reply to: Fun with NULL pointers, part 1 by nhippi
Parent article: Fun with NULL pointers, part 1

(1) Coverity has checks for this. The error is so common that it makes up a large fraction of warnings in typical Coverity reports.

(2) Gcc certainly should have a warning for this. However, putting such a warning in "-W" would make people upset (see (1)). That's not meant to be an argument against. It might be easier to get it into -Wall, but it is generally very hard to move a warning from -W to -Wall or the reverse, so if it gets into -Wall it is probably stuck there forever. The warning would likely be issued only when compiling with strong optimization; without optimization the compiler would be unlikely to perform the analysis that would lead to it noticing the problem.

(3) Depending on the offset within the struct type pointed to, the pointer value dereferenced might not refer to zero page, and thus might not trigger a SEGV signal in normal user-level code, even without memory-mapping games.

(Log in to post comments)

Fun with NULL pointers, part 1

Posted Jul 22, 2009 2:18 UTC (Wed) by Baylink (guest, #755) [Link]

Am I the only person who read "has checks for this" and thought "a wart is a crocky feature"?

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