[U-Boot] [PATCH v4] TI DaVinci: Driver for the davinci SPI controller
Mike Frysinger
vapier at gentoo.org
Wed Jan 6 19:51:44 CET 2010
On Wednesday 06 January 2010 06:18:21 Sudhakar Rajashekhara wrote:
> + ds = malloc(sizeof(struct davinci_spi_slave));
personally i find sizeof(*ds) to be better
> +void spi_free_slave(struct spi_slave *slave)
> +{
> + struct davinci_spi_slave *ds = to_davinci_spi(slave);
> +
> + if (ds) {
> + free(ds);
> + ds = NULL;
> + }
> +}
free() already does a NULL pointer check, and assigning NULL to a stack
variable is pointless. i.e. this function should simply be:
free(slave);
> +static inline struct davinci_spi_slave *to_davinci_spi(struct spi_slave
> *slave) +{
> + if (!slave)
> + return NULL;
> + else
> + return container_of(slave, struct davinci_spi_slave, slave);
> +}
this logic is pointless ... container_of() on a NULL pointer is a NULL
pointer, and it isnt like container_of() will deref the pointer causing a
crash.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100106/57529085/attachment.pgp
More information about the U-Boot
mailing list