Re: [PATCH 2/2] iio: Add driver for Murata IRS-D200
From: Jonathan Cameron
Date: Sat Jul 15 2023 - 12:55:47 EST
On Wed, 12 Jul 2023 17:33:09 +0200
Waqar Hameed <waqar.hameed@xxxxxxxx> wrote:
> On Sun, Jun 25, 2023 at 12:06 +0100 Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> [...]
>
> >> >> + dev_err(data->dev, "Could not write hp filter frequency (%d)\n",
> >> >> + ret);
> >> >> + return ret;
> >> >
> >> > drop this return ret out of the if block here.
> >> >
> >> > In general being able to ignore possibility of ret > 0 simplifies handling.
> >>
> >> I try to be consistent and it also "helps" the next person potentially
> >> adding code after the `if`-statement and forgetting about adding
> >> `return`. We can drop the `return here, but then we should do the same
> >> in other places with a check just before the last `return` (like
> >> `irsd200_write_timer()`, `irsd200_read_nr_count()`,
> >> `irsd200_write_nr_count()` and many more), right?
> >
> > I don't feel particulartly strongly about this, but there are scripts
> > that get used to scan for this pattern to simplify the code.
> >
> > Sure on the other cases. I don't tend to try and label all cases of things
> > pointed out, just pick on one and rely on the patch author to generalise.
>
> I started to remove the returns but then realized that it got a little
> messy. For example, in some cases we can't drop the return (side effects
> after the return etc.).
>
> Since you didn't have any strong opinions on this, I kept them in v2.
> Hope that's fine!
Absolutely. I wasn't advocating removing separate returns in general, just this
cases where there was nothing after the if check.
Thanks,
Jonathan