[webkit-dev] Eliminate potential null pointer dereference?

Shezan Baig shezbaig.wk at gmail.com
Fri Apr 20 12:14:55 PDT 2012

On Fri, Apr 20, 2012 at 3:06 PM, Filip Pizlo <fpizlo at apple.com> wrote:
> Someone in this thread said something about code readability. So let's
> consider that. If I see code like:
> if (!var) thingy();
> Then I will be under the impression that var might sometimes be zero and
> that thingy() might sometimes happen, and that the previous webkittens to
> touch this code had a good reason for this check.
> Coverity is no more accurate than testing; if it tells you that var might be
> zero than it cannot, will not, and does not give you 100% confidence that
> this is reachable.
> Hence if you add special cases for things that coverity warned you about,
> you are potentially doing a disservice to anyone looking at the code in the
> future. You are telling them that "var might be zero" when really you meant
> to say "I put in this check to get my tool to stop complaining".
> On the other hand, if you are able to construct a test that demonstrates
> reachability then you win. But if there is no test then see my previous
> paragraph.

Wouldn't an ASSERT be more helpful in this case, i.e. something like:


Does ASSERT make coverity stop giving out warnings?

More information about the webkit-dev mailing list