aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Bolle <pebolle@tiscali.nl>2013-02-08 01:57:55 -0500
committerJames Bottomley <JBottomley@Parallels.com>2013-02-22 07:53:31 -0500
commitf24b697ba499f971e84478f531de77ede9a2aac1 (patch)
tree2645c9ffffed1c9aa46fee4eae67c2580ebd4d02
parent1e63395ce04f6d64f67c64d87762d2b6d48ec4d4 (diff)
[SCSI] qla2xxx: silence two GCC warnings.
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.) An easy way to silence these warnings is to use preprocessor macros and strncpy, as that apparently gives GCC enough information to keep track of array bounds. Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c8
2 files changed, 5 insertions, 4 deletions
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 5c1a86584079..3d980a21f479 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -37,6 +37,7 @@
37#include "qla_nx.h" 37#include "qla_nx.h"
38#define QLA2XXX_DRIVER_NAME "qla2xxx" 38#define QLA2XXX_DRIVER_NAME "qla2xxx"
39#define QLA2XXX_APIDEV "ql2xapidev" 39#define QLA2XXX_APIDEV "ql2xapidev"
40#define QLA2XXX_MANUFACTURER "QLogic Corporation"
40 41
41/* 42/*
42 * We have MAILBOX_REGISTER_COUNT sized arrays in a few places, 43 * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 40c5933743a4..9b455250c101 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1328,8 +1328,8 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
1328 /* Manufacturer. */ 1328 /* Manufacturer. */
1329 eiter = (struct ct_fdmi_hba_attr *) (entries + size); 1329 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1330 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); 1330 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER);
1331 strcpy(eiter->a.manufacturer, "QLogic Corporation"); 1331 alen = strlen(QLA2XXX_MANUFACTURER);
1332 alen = strlen(eiter->a.manufacturer); 1332 strncpy(eiter->a.manufacturer, QLA2XXX_MANUFACTURER, alen + 1);
1333 alen += (alen & 3) ? (4 - (alen & 3)) : 4; 1333 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1334 eiter->len = cpu_to_be16(4 + alen); 1334 eiter->len = cpu_to_be16(4 + alen);
1335 size += 4 + alen; 1335 size += 4 + alen;
@@ -1649,8 +1649,8 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
1649 /* OS device name. */ 1649 /* OS device name. */
1650 eiter = (struct ct_fdmi_port_attr *) (entries + size); 1650 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1651 eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); 1651 eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
1652 strcpy(eiter->a.os_dev_name, QLA2XXX_DRIVER_NAME); 1652 alen = strlen(QLA2XXX_DRIVER_NAME);
1653 alen = strlen(eiter->a.os_dev_name); 1653 strncpy(eiter->a.os_dev_name, QLA2XXX_DRIVER_NAME, alen + 1);
1654 alen += (alen & 3) ? (4 - (alen & 3)) : 4; 1654 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1655 eiter->len = cpu_to_be16(4 + alen); 1655 eiter->len = cpu_to_be16(4 + alen);
1656 size += 4 + alen; 1656 size += 4 + alen;