lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <304d3bcef438a78564650edd52f7570f0bd30c95.camel@gmail.com>
Date: Thu, 12 Jun 2025 07:41:40 +0100
From: Nuno Sá <noname.nuno@...il.com>
To: Andrew Ijano <andrew.ijano@...il.com>, jic23@...nel.org
Cc: andrew.lopes@...mni.usp.br, gustavobastos@....br, dlechner@...libre.com,
  nuno.sa@...log.com, andy@...nel.org, jstephan@...libre.com, 
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 1/3] iio: accel: sca3000: replace error_ret labels by
 simple returns

On Thu, 2025-06-12 at 07:20 +0100, Nuno Sá wrote:
> On Wed, 2025-06-11 at 16:39 -0300, Andrew Ijano wrote:
> > Replace usage of error_ret labels by returning directly when handling
> > errors. Cases that do a mutex unlock were not changed.
> > 
> > Signed-off-by: Andrew Ijano <andrew.lopes@...mni.usp.br>
> > Co-developed-by: Gustavo Bastos <gustavobastos@....br>
> > Signed-off-by: Gustavo Bastos <gustavobastos@....br>
> > Suggested-by: Jonathan Cameron <jic23@...nel.org>
> > ---
> 
> Code looks good. But since you're doing this you could cleanup some of the switch()
> cases. Some return in every case statement while other don't (even think I saw one
> one place where 'return' in the end was not needed). IIRC, there's preference for
> returning in place.
> 

I see the above could be a bit cumbersome in cases there's locking (which get's
cleaned up in patch 3). So, nevermind the above. If there's any leftover, you can
send a follow up patch or introduce a new patch if you need to re-spin.

For this one:

Reviewed-by: Nuno Sá <nuno.sa@...log.com>

> 
> >  drivers/iio/accel/sca3000.c | 29 +++++++++++------------------
> >  1 file changed, 11 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> > index aabe4491efd7..bfa8a3f5a92f 100644
> > --- a/drivers/iio/accel/sca3000.c
> > +++ b/drivers/iio/accel/sca3000.c
> > @@ -369,23 +369,20 @@ static int sca3000_write_ctrl_reg(struct sca3000_state *st,
> >  
> >  	ret = sca3000_reg_lock_on(st);
> >  	if (ret < 0)
> > -		goto error_ret;
> > +		return ret;
> >  	if (ret) {
> >  		ret = __sca3000_unlock_reg_lock(st);
> >  		if (ret)
> > -			goto error_ret;
> > +			return ret;
> >  	}
> >  
> >  	/* Set the control select register */
> >  	ret = sca3000_write_reg(st, SCA3000_REG_CTRL_SEL_ADDR, sel);
> >  	if (ret)
> > -		goto error_ret;
> > +		return ret;
> >  
> >  	/* Write the actual value into the register */
> > -	ret = sca3000_write_reg(st, SCA3000_REG_CTRL_DATA_ADDR, val);
> > -
> > -error_ret:
> > -	return ret;
> > +	return sca3000_write_reg(st, SCA3000_REG_CTRL_DATA_ADDR, val);
> >  }
> >  
> >  /**
> > @@ -402,22 +399,20 @@ static int sca3000_read_ctrl_reg(struct sca3000_state *st,
> >  
> >  	ret = sca3000_reg_lock_on(st);
> >  	if (ret < 0)
> > -		goto error_ret;
> > +		return ret;
> >  	if (ret) {
> >  		ret = __sca3000_unlock_reg_lock(st);
> >  		if (ret)
> > -			goto error_ret;
> > +			return ret;
> >  	}
> >  	/* Set the control select register */
> >  	ret = sca3000_write_reg(st, SCA3000_REG_CTRL_SEL_ADDR, ctrl_reg);
> >  	if (ret)
> > -		goto error_ret;
> > +		return ret;
> >  	ret = sca3000_read_data_short(st, SCA3000_REG_CTRL_DATA_ADDR, 1);
> >  	if (ret)
> > -		goto error_ret;
> > +		return ret;
> >  	return st->rx[0];
> > -error_ret:
> > -	return ret;
> >  }
> >  
> >  /**
> > @@ -577,7 +572,8 @@ static inline int __sca3000_get_base_freq(struct
> > sca3000_state
> > *st,
> >  
> >  	ret = sca3000_read_data_short(st, SCA3000_REG_MODE_ADDR, 1);
> >  	if (ret)
> > -		goto error_ret;
> > +		return ret;
> > +
> >  	switch (SCA3000_REG_MODE_MODE_MASK & st->rx[0]) {
> >  	case SCA3000_REG_MODE_MEAS_MODE_NORMAL:
> >  		*base_freq = info->measurement_mode_freq;
> > @@ -591,7 +587,6 @@ static inline int __sca3000_get_base_freq(struct
> > sca3000_state
> > *st,
> >  	default:
> >  		ret = -EINVAL;
> >  	}
> > -error_ret:
> >  	return ret;
> >  }
> >  
> > @@ -834,7 +829,7 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
> >  	val = st->rx[0];
> >  	mutex_unlock(&st->lock);
> >  	if (ret)
> > -		goto error_ret;
> > +		return ret;
> >  
> >  	switch (val & SCA3000_REG_MODE_MODE_MASK) {
> >  	case SCA3000_REG_MODE_MEAS_MODE_NORMAL:
> > @@ -857,8 +852,6 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
> >  		break;
> >  	}
> >  	return len;
> > -error_ret:
> > -	return ret;
> >  }
> >  
> >  /*
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ