[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <431f26fb-5943-eb58-9ad5-eda787966ad2@redhat.com>
Date: Fri, 11 Feb 2022 13:11:25 +0100
From: Javier Martinez Canillas <javierm@...hat.com>
To: Jani Nikula <jani.nikula@...ux.intel.com>,
Thomas Zimmermann <tzimmermann@...e.de>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: linux-fbdev@...r.kernel.org, David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel.vetter@...ll.ch>,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
Noralf Trønnes <noralf@...nnes.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Maxime Ripard <maxime@...no.tech>,
Sam Ravnborg <sam@...nborg.org>
Subject: Re: [PATCH v4 1/6] drm/format-helper: Add
drm_fb_xrgb8888_to_gray8_line()
Hello Jani,
On 2/11/22 13:05, Jani Nikula wrote:
[snip]
>>>> I don't see why a while loop would be an improvement here TBH.
>>>
>>> Less letters to parse when reading the code.
>>
>> It's a simple refactoring of code that has worked well so far. Let's
>> leave it as-is for now.
>
> IMO *always* prefer a for loop over while or do-while.
>
> The for (i = 0; i < N; i++) is such a strong paradigm in C. You
> instantly know how many times you're going to loop, at a glance. Not so
> with with the alternatives, which should be used sparingly.
>
> And yes, the do-while suggested above is buggy, and you actually need to
> stop and think to see why.
>
Absolutely agree.
These format conversion helpers are not trivial to read and understand (at
least for me). In my opinion the code should be written in a way that ease
readability and make as robust and less error prone as possible.
>
> BR,
> Jani.
Best regards,
--
Javier Martinez Canillas
Linux Engineering
Red Hat
Powered by blists - more mailing lists