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: <5ee24960-7843-827a-2c47-b93a4b4798e3@suse.de>
Date:   Mon, 14 Feb 2022 13:12:48 +0100
From:   Thomas Zimmermann <tzimmermann@...e.de>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Jani Nikula <jani.nikula@...ux.intel.com>,
        Javier Martinez Canillas <javierm@...hat.com>,
        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()

Hi

Am 14.02.22 um 11:38 schrieb Andy Shevchenko:
> On Mon, Feb 14, 2022 at 10:03:53AM +0100, Thomas Zimmermann wrote:
>> 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.
> 
> In the section 3.5 "Loops - While and For" in "The C Programming
> Language" 2nd by K&R, the authors said:

Year of publication: 1988 . It's not the most up-to-date reference for C 
programming.

> 
> 	The for statement ... is equivalent to ... while..."
> 
> They said that for is equivalent to while, and not otherwise.

Even leaving readability aside, it's not equivalent. You can declare 
variables as part of the for statement. (I know it's not the kernel's 
style.) Also, 'continue' statements are not well-suited in for loops, 
because it's non-obvious if the loop's update statement is being 
executed. (It isn't.)

> 
> Also, syntax sugar by definition declares something that can be written as
> a single line of code, which usually is done using more (not always).

The discussion has entered the phase of hair splitting. Good.

Best regards
Thomas

> 
>> 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.
> 
>>>> 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

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (841 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ