public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Do not misuse Coverity please (Was: sound/oss/cs46xx.c: fix a check after use)
@ 2005-03-30  1:25 Horst von Brand
  2005-03-30  7:53 ` Do not misuse Coverity please Jean Delvare
  0 siblings, 1 reply; 2+ messages in thread
From: Horst von Brand @ 2005-03-30  1:25 UTC (permalink / raw)
  To: Jean Delvare; +Cc: akpm, Adrian Bunk, LKML

"Jean Delvare" <khali@linux-fr.org> said:

[Sttributions missing, sorry]

> > >  Think about it. If the pointer could be NULL, then it's unlikely that
> > >  the bug would have gone unnoticed so far (unless the code is very
> > >  recent). Coverity found 3 such bugs in one i2c driver [1], and the
> > >  correct solution was to NOT check for NULL because it just couldn't
> > >  happen.

> > No, there is a third case: the pointer can be NULL, but the compiler
> > happened to move the dereference down to after the check.

> Wow. Great point. I completely missed that possibility. In fact I didn't
> know that the compiler could possibly alter the order of the
> instructions. For one thing, I thought it was simply not allowed to. For
> another, I didn't know that it had been made so aware that it could
> actually figure out how to do this kind of things. What a mess. Let's
> just hope that the gcc folks know their business :)

The compiler is most definitely /not/ allowed to change the results the
code gives.
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-30 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <3NC4e-1X1-21@gated-at.bofh.it>
     [not found] ` <3NGrd-5rX-21@gated-at.bofh.it>
     [not found]   ` <3NQgW-5h6-41@gated-at.bofh.it>
     [not found]     ` <3NR3q-5YI-59@gated-at.bofh.it>
     [not found]       ` <3NUDL-DU-13@gated-at.bofh.it>
2005-03-30 23:57         ` Big GCC bug!!! [Was: Re: Do not misuse Coverity please] Robert Hancock
2005-03-30  1:25 Do not misuse Coverity please (Was: sound/oss/cs46xx.c: fix a check after use) Horst von Brand
2005-03-30  7:53 ` Do not misuse Coverity please Jean Delvare
2005-03-30 18:29   ` Shankar Unni
2005-03-30 19:14     ` Paulo Marques
2005-03-30 23:11       ` Big GCC bug!!! [Was: Re: Do not misuse Coverity please] Kyle Moffett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox