linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: Paul Bolle <pebolle@tiscali.nl>, linux-scsi@vger.kernel.org
Cc: Andrew Vasquez <andrew.vasquez@qlogic.com>,
	linux-driver@qlogic.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] qla2xxx: silence two GCC warnings
Date: Sun, 30 Sep 2012 23:21:30 +0200	[thread overview]
Message-ID: <3591681.K68OpP9yPi@eto> (raw)
In-Reply-To: <1349003274.15306.6.camel@x61.thuisdomein>

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

Am Sonntag 30 September 2012, 13:07:54 schrieb Paul Bolle:
> Compiling qla_gs.o (part of the qla2xxx module) triggers two GCC
> warnings:
>     drivers/scsi/qla2xxx/qla_gs.c: In function ‘qla2x00_fdmi_rhba’:
>     drivers/scsi/qla2xxx/qla_gs.c:1339:7: warning: array subscript is above
> array bounds [-Warray-bounds] drivers/scsi/qla2xxx/qla_gs.c: In function
> ‘qla2x00_fdmi_register’: drivers/scsi/qla2xxx/qla_gs.c:1663:15: warning:
> array subscript is above array bounds [-Warray-bounds]
> 
> It seems that the sequence of a strcpy followed by a strlen confuses GCC
> when it is keeping track of array bounds here. (It is not clear to me
> which array triggers this warning and by how much GCC thinks the
> subscript is above its bounds. Neither is it clear to me why comparable
> code in these two functions doesn't trigger this warning.)
> 
> The easiest way to silence these warnings is to hardcode the length of
> these two strings in the code here. The length used here is the length
> of the string, including its NUL terminator, rounded up to the next
> multiple of four.

This adds some magic values, which is asking for trouble once someone changes 
the manufacturer string or something. What about something like this:

const char *qlogic = "QLogic Corporation";
strcpy(eiter->a.manufacturer, qlogic);
alen += round_up(strlen(qlogic), 4);
...

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2012-09-30 21:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-30 11:07 [PATCH] qla2xxx: silence two GCC warnings Paul Bolle
2012-09-30 21:21 ` Rolf Eike Beer [this message]
2012-10-02  7:42   ` [PATCH v2] " Paul Bolle
2012-10-04 17:42     ` Saurav Kashyap
2012-10-05 12:23       ` [PATCH v3] " Paul Bolle
2012-10-08 16:15         ` Saurav Kashyap
2013-01-29  9:57           ` Paul Bolle
2013-01-30  8:07             ` Saurav Kashyap
2013-01-30  8:14               ` Paul Bolle

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=3591681.K68OpP9yPi@eto \
    --to=eike-kernel@sf-tec.de \
    --cc=andrew.vasquez@qlogic.com \
    --cc=linux-driver@qlogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=pebolle@tiscali.nl \
    /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).