public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Ser, Simon" <simon.ser@intel.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
	"chris@chris-wilson.co.uk" <chris@chris-wilson.co.uk>
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/gen_mmap: fix no-op loops
Date: Wed, 08 May 2019 14:27:56 +0300	[thread overview]
Message-ID: <87sgtpkwxv.fsf@intel.com> (raw)
In-Reply-To: <d79ffc569927028ceddfb0c66b1f31602b147422.camel@intel.com>

On Tue, 07 May 2019, "Ser, Simon" <simon.ser@intel.com> wrote:
> On Tue, 2019-05-07 at 15:31 +0100, Chris Wilson wrote:
>> Quoting Simon Ser (2019-05-07 13:44:41)
>> > The loop condition is never satisfied, since after filling the
>> > array i > 0. For
>> > this reason the loop is always a no-op.
>> > 
>> > Use a more conventional loop instead.
>> 
>> Or a classic while loop? Bad me for not reading the check was
>> back-to-front.
>
> You mean while(i--)?
>
> I generally prioritize code clarity in these situations, hence the for
> loop. Also not a fan of decrementing operators returning a value.

FWIW I always go for (i = 0; i < N; i++). It takes half an eyeblink for
that to sink in.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-05-08 11:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07 12:44 [igt-dev] [PATCH i-g-t] tests/i915/gen_mmap: fix no-op loops Simon Ser
2019-05-07 13:54 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-05-07 14:31 ` [igt-dev] [PATCH i-g-t] " Chris Wilson
2019-05-07 15:10   ` Ser, Simon
2019-05-08 11:27     ` Jani Nikula [this message]
2019-05-07 18:42 ` [igt-dev] ✗ Fi.CI.IGT: failure for " Patchwork
2019-05-08  9:54   ` Ser, Simon
2019-05-20  6:26     ` Ser, Simon
2019-05-27 15:25     ` Ser, Simon
2019-05-31 11:36     ` Ser, Simon
2019-05-31 11:41       ` Chris Wilson
2019-05-31 11:52         ` Ser, Simon
2019-06-03 15:18           ` Daniel Vetter
2019-05-10 15:39 ` [igt-dev] [PATCH i-g-t] " Antonio Argenziano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgtpkwxv.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=simon.ser@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox