linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@prisktech.co.nz (Tony Prisk)
To: linux-arm-kernel@lists.infradead.org
Subject: Array subscript above array bounds warning
Date: Sun, 28 Apr 2013 13:37:01 +1200	[thread overview]
Message-ID: <517C7D3D.50207@prisktech.co.nz> (raw)
In-Reply-To: <517C653B.7050908@elopez.com.ar>

On 28/04/13 11:54, Emilio L?pez wrote:
> El 27/04/13 20:29, Tony Prisk escribi?:
>> Could someone clarify for me what I am missing here?
>>
>>
>> in drivers/net/ethernet/via/velocity.h is the following definition:
>>
>> struct mac_regs {
>> volatile u8 PAR[6]; /* 0x00 */
>> ...
>> }
>>
>> I am trying to add the following function but it keeps giving array
>> bounds warnings:
>>
>> static void velocity_set_power_state(struct velocity_info *vptr, char
>> state)
>> {
>> struct mac_regs __iomem *regs = vptr->mac_regs;
>>
>> if (vptr->bustype == BUS_PCI) {
>> pci_set_power_state(vptr->pdev, state);
>> } else {
>> writeb(state, (&regs->PAR[0]) + 0x154);
> This would be equivalent to
>
> writeb(state, regs->PAR + 0x154);
>
> or
>
> writeb(state, &regs->PAR[340]);
>
> Which would be out of bounds, right? As it's an u8 array with just 6
> elements, not 341+
Yeah sorry - stupid question.

I just thought about the code while out for a walk and realised I should 
have looked at what the original author was trying to do rather than 
copy it verbatim.I have solved the issue now.

Regards
Tony P

      reply	other threads:[~2013-04-28  1:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 23:29 Array subscript above array bounds warning Tony Prisk
2013-04-27 23:54 ` Emilio López
2013-04-28  1:37   ` Tony Prisk [this message]

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=517C7D3D.50207@prisktech.co.nz \
    --to=linux@prisktech.co.nz \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).