[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230318164909.06123384@jic23-huawei>
Date: Sat, 18 Mar 2023 16:49:09 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Matti Vaittinen <mazziesaccount@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
"Vaittinen, Matti" <Matti.Vaittinen@...rohmeurope.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Paul Gazzillo <paul@...zz.com>,
Dmitry Osipenko <dmitry.osipenko@...labora.com>,
Shreeya Patel <shreeya.patel@...labora.com>,
Zhigang Shi <Zhigang.Shi@...eon.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>
Subject: Re: [PATCH v2 2/6] iio: light: Add gain-time-scale helpers
On Tue, 14 Mar 2023 12:28:43 +0200
Matti Vaittinen <mazziesaccount@...il.com> wrote:
> On 3/13/23 16:39, Andy Shevchenko wrote:
> > On Mon, Mar 13, 2023 at 01:31:42PM +0200, Matti Vaittinen wrote:
> >> On 3/6/23 13:13, Andy Shevchenko wrote:
> >>> On Fri, Mar 03, 2023 at 07:54:22AM +0000, Vaittinen, Matti wrote:
> >>>> On 3/2/23 17:05, Andy Shevchenko wrote:
> >>>>> On Thu, Mar 02, 2023 at 12:57:54PM +0200, Matti Vaittinen wrote:
> >
> > ...
> >
> >>>>>> + for (i = 0; !ret && i < gts->num_avail_all_scales; i++)
> >>>>>
> >>>>> Much easier to read if you move this...
> >>>>>
> >>>>>> + ret = iio_gts_total_gain_to_scale(gts, all_gains[i],
> >>>>>> + >s->avail_all_scales_table[i * 2],
> >>>>>> + >s->avail_all_scales_table[i * 2 + 1]);
> >>>>>
> >>>>> ...here as
> >>>>>
> >>>>> if (ret)
> >>>>> break;
> >>>>
> >>>> I think the !ret in loop condition is obvious. Adding break and brackets
> >>>> would not improve this.
> >>>
> >>> It moves it to the regular pattern. Yours is not so distributed in the kernel.
> >>
> >> I believe we can find examples of both patterns in kernel. I don't think the
> >> "many people use different pattern" is a great reason to add break +
> >> brackets which (in my eyes) give no additional value to code I am planning
> >> to keep reading also in the future...
> >
> > The problem is that your pattern is not so standard (distributed) and hence
> > less maintainable.
>
> I am sorry but I can't really agree with you on this one. For me adding
> the break and brackets would just complicate the flow and thus decrease
> the maintainability.
I'm with the if (ret) break;
school of thought on this one. Never like for loops with complex conditions,
I guess because I've trained my eyes to ignore them ;)
Powered by blists - more mailing lists