On Mon, Mar 28, 2005 at 10:23:48PM -0800, Andrew Morton wrote:
> > > - int old=card->amplifier;
> > > + int old;
> > > if(!card)
> > > {
> > > CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO
> > > "cs46xx: amp_hercules() called before initialized.\n"));
> > > return;
> > > }
> > > + old = card->amplifier;
> No, there is a third case: the pointer can be NULL, but the compiler
> happened to move the dereference down to after the check.
>
> If the optimiser is later changed, or if someone tries to compile the code
> with -O0, it will oops.
The thing GCC is most likely to do with this code is discard the NULL
check entirely and leave only the oops; the "if (!card)" can not be
reached without passing through "card->amplifier", and a pointer which
is dereferenced can not be NULL in a valid program.
--
Daniel Jacobowitz
CodeSourcery, LLC
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]