Re: [RFC, PATCH 1/3] gpiodev - API definitions

From: Russell King
Date: Wed Apr 11 2007 - 03:42:40 EST


On Wed, Apr 11, 2007 at 08:47:01AM +0200, Juergen Schindele wrote:
> Am Dienstag, 10. April 2007 23:30 schrieb Paul Sokolovsky:
> > +static inline int gpiodev_get_value(struct gpio *gpio)
> > +{
> > + struct gpiodev_ops *ops = gpio->gpio_dev->dev.platform_data;
>
> wouldn't it be more sure to verify if xxx function is NOT null
> before using it ?? Perhaps something like that
> BUG_ON(!ops->get);
>
> > + return ops->get(&gpio->gpio_dev->dev, gpio->gpio_no);

What does the BUG_ON buy us that oopsing due to a NULL pointer deref
doesn't? Both cases you end up with a register dump and backtrace.
In fact, on ARM the NULL pointer deref provides a more accurate
register dump and backtrace than BUG_ON() can ever do.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/