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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux