[PATCH v4 1/6] drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line()

Thomas Zimmermann tzimmermann at suse.de
Mon Feb 14 09:03:53 UTC 2022


Hi

Am 11.02.22 um 16:41 schrieb Andy Shevchenko:
[...]
>> 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.
> 
> while () {}  _is_ a paradigm, for-loop is syntax sugar on top of it.

Naw, that's not true. An idiomatic for loop, such as for (i = ...; i < 
N; ++i), is such a strong pattern that it's way better than the 
corresponding while loop.

Best regards
Thomas

> 
>> And yes, the do-while suggested above is buggy, and you actually need to
>> stop and think to see why.
> 
> It depends if pixels can be 0 or not and if it's not, then does it contain last
> or number.
> 
> The do {} while (--pixels); might be buggy iff pixels may be 0.
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20220214/74c0fff9/attachment-0001.sig>


More information about the dri-devel mailing list