From: Thomas Gleixner <tglx@linutronix.de>
To: David Binderman <dcb314@hotmail.com>
Cc: "jason@lakedaemon.net" <jason@lakedaemon.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ?
Date: Mon, 8 Jun 2015 15:26:12 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.11.1506081523510.4133@nanos> (raw)
In-Reply-To: <DUB128-W618D35E0256A8A879EAAE09CBF0@phx.gbl>
On Mon, 8 Jun 2015, David Binderman wrote:
> ----------------------------------------
> >> [linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418]: (style) Array ind
> >> ex 'k' is used before limits check.
> >>
> >> if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
> >>
> >> Suggest sanity check array index before use.
> >
> > Which version of gcc is being stupid here?
>
> None of them.
>
> The original "(style)" message is from a static analysis tool called cppcheck.
>
> I can't think of a situation where, if an array index needs checking, then
> it should be checked *after* use.
It does not check the array index. Read the complete code:
for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
The array bound is INTC_IRQPIN_REG_NR and the check about which that
tool complains has nothing to do with array bounds. Completely valid
code.
Thanks,
tglx
next prev parent reply other threads:[~2015-06-08 13:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-08 11:05 David Binderman
2015-06-08 13:10 ` Thomas Gleixner
2015-06-08 13:16 ` David Binderman
2015-06-08 13:26 ` Thomas Gleixner [this message]
2015-06-08 16:40 ` David Binderman
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=alpine.DEB.2.11.1506081523510.4133@nanos \
--to=tglx@linutronix.de \
--cc=dcb314@hotmail.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
/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®