[lm-sensors] [PATCH 2.6.13-mm1] i2c: bug fix for busses/i2c-mv64xxx.c

Jean Delvare khali at linux-fr.org
Tue Sep 6 22:20:25 CEST 2005


Hi Mark,

> >  mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
> >  int num) {
> >  	struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap);
> > -	int	i, rc = 0;
> > +	int	i, rc;
> >  
> >  	for (i=0; i<num; i++)
> > -		if ((rc = mv64xxx_i2c_execute_msg(drv_data, &msgs[i])) != 0)
> > -			break;
> > +		if ((rc = mv64xxx_i2c_execute_msg(drv_data, &msgs[i])) < 0)
> > +			return rc;
> >  
> > -	return rc;
> > +	return num;
> >  }
> 
> Agreed.  However, I think we still need to init 'rc' to 0 in case
> 'num' is ever 0 to prevent random data from being returned.

If num is 0, the for loop is never entered and num, not rc, is returned.
Thus I don't see why initializing rc to 0 would be needed. Or am I
missing something obvious?

-- 
Jean Delvare




More information about the lm-sensors mailing list