From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Andy Shevchenko <andy@kernel.org>,
Linus Walleij <linusw@kernel.org>
Subject: Re: [PATCH v1 5/5] pinctrl: intel: define iterator variables inside for-loop
Date: Thu, 19 Mar 2026 09:20:51 +0200 [thread overview]
Message-ID: <abuj05EIZcO10wQa@ashevche-desk.local> (raw)
In-Reply-To: <20260319070925.GS2275908@black.igk.intel.com>
On Thu, Mar 19, 2026 at 08:09:25AM +0100, Mika Westerberg wrote:
> On Thu, Mar 19, 2026 at 08:57:58AM +0200, Andy Shevchenko wrote:
> > On Thu, Mar 19, 2026 at 07:02:21AM +0100, Mika Westerberg wrote:
> > > On Wed, Mar 18, 2026 at 04:10:19PM +0100, Andy Shevchenko wrote:
...
> > > > - int i;
> > >
> > > If there are multiple loops, I prefer to declare the variable outside of
> > > them.
> >
> > Why?! It's exactly where it make even more sense to hide.
>
> I disagree.
Why? Can you give a constructive feedback, please?
> > > If it is just a single loop then for (int i = 0, ..) is fine.
...
> > > > - for (i = 0; i < grp->grp.npins; i++) {
> > > > + for (unsigned int i = 0; i < grp->grp.npins; i++) {
> > >
> > > also why you use "unsigned int". int i is fine here.
> >
> > Because grp.npins is unsigned. This is the common sense to use the same
> > variable type that's used for the (upper) limit.
>
> No, just use "int i" there. Compiler is fine and this is more idiomatic C
> anyways.
I can agree on this, but it (in this case theoretically) might lead to subtle
signdness issues if compiler is not capable to see the upper limit and predict
no overflow or wrap-around.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-03-19 7:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 15:10 [PATCH v1 0/5] pinctrl: intel: capability handling rework Andy Shevchenko
2026-03-18 15:10 ` [PATCH v1 1/5] pinctrl: intel: Improve capability support Andy Shevchenko
2026-03-19 5:57 ` Mika Westerberg
2026-03-19 7:00 ` Andy Shevchenko
2026-03-18 15:10 ` [PATCH v1 2/5] pinctrl: intel: Fix the revision for new features (1kOhm PD, HW debouncer) Andy Shevchenko
2026-03-19 5:58 ` Mika Westerberg
2026-03-19 7:00 ` Andy Shevchenko
2026-03-18 15:10 ` [PATCH v1 3/5] pinctrl: intel: Enable 3-bit PAD_OWN feature Andy Shevchenko
2026-03-19 5:58 ` Mika Westerberg
2026-03-19 7:00 ` Andy Shevchenko
2026-03-18 15:10 ` [PATCH v1 4/5] pinctrl: intel: Refactor intel_gpio_add_pin_ranges() to make it shorter Andy Shevchenko
2026-03-19 6:03 ` Mika Westerberg
2026-03-19 6:56 ` Andy Shevchenko
2026-03-19 7:07 ` Mika Westerberg
2026-03-19 7:18 ` Andy Shevchenko
2026-03-18 15:10 ` [PATCH v1 5/5] pinctrl: intel: define iterator variables inside for-loop Andy Shevchenko
2026-03-19 6:02 ` Mika Westerberg
2026-03-19 6:57 ` Andy Shevchenko
2026-03-19 7:09 ` Mika Westerberg
2026-03-19 7:20 ` Andy Shevchenko [this message]
2026-03-19 10:41 ` Mika Westerberg
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=abuj05EIZcO10wQa@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.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
all inboxes | Powered by JetHome®