mci/stm378x warning

Sascha Hauer s.hauer at pengutronix.de
Mon Jan 31 09:01:23 EST 2011


On Mon, Jan 31, 2011 at 02:34:35PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	durring some night build I see this on the drivers/mci/stm378x.c
> 
> 	/opt/work/barebox/drivers/mci/stm378x.c: In function 'mci_request':
> 	/opt/work/barebox/drivers/mci/stm378x.c:354: warning: 'length' may be used uninitialized in this function
> 	/opt/work/barebox/drivers/mci/stm378x.c:354: note: 'length' was declared here
> 
> 	so I guess length will initialized at 0

That's a false positive:

> static int transfer_data(struct device_d *hw_dev, struct mci_data *data)
> {
> 	unsigned length;
> 
> 	if (data != NULL) {
> 		length = data->blocks * data->blocksize;
> 	}

When we have date length gets initialized...

> 
> 	/*
> 	 * Everything is ready for the transaction now:
> 	 * - transfer configuration
> 	 * - command and its parameters
> 	 *
> 	 * Start the transaction right now
> 	 */
> 	writel(SSP_CTRL0_RUN, hw_dev->map_base + HW_SSP_CTRL0 + 4);
> 
> 	if (data != NULL) {

...and is only used in the same case.

> 		if (data->flags & MMC_DATA_READ)
> 			return read_data(hw_dev, data->dest, length);
> 		else
> 			return write_data(hw_dev, data->src, length);
> 	}
> 
> 	return 0;

Anyway, we should silence the compiler somehow. I'll prepare a patch for
this.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list