Re: [PATCH v3] qla2xxx: silence two GCC warnings

2013-01-30 Thread Saurav Kashyap


On Mon, 2012-10-08 at 11:15 -0500, Saurav Kashyap wrote:
 Acked-by: Saurav Kashyap saurav.kash...@qlogic.com

 Thanks,
 ~Saurav

 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]

This patch was originally posted to silence two GCC warnings while
building v3.6-rc7. Basically identical warnings can still be seen while
building v3.8-rc5. What's the status of this patch?

Hi Paul,
I am submitting some correction patches today and this patch will be part
of the scsi-misc submission after that set.

Thanks,
~Saurav


Paul Bolle

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html





This message and any attached documents contain information from QLogic 
Corporation or its wholly-owned subsidiaries that may be confidential. If you 
are not the intended recipient, you may not read, copy, distribute, or use this 
information. If you have received this transmission in error, please notify the 
sender immediately by reply e-mail and then delete this message.


Re: [PATCH v3] qla2xxx: silence two GCC warnings

2013-01-30 Thread Paul Bolle
On Wed, 2013-01-30 at 08:07 +, Saurav Kashyap wrote:
 I am submitting some correction patches today and this patch will be part
 of the scsi-misc submission after that set.

Thanks.


Paul Bolle

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] qla2xxx: silence two GCC warnings

2013-01-29 Thread Paul Bolle
On Mon, 2012-10-08 at 11:15 -0500, Saurav Kashyap wrote:
 Acked-by: Saurav Kashyap saurav.kash...@qlogic.com
 
 Thanks,
 ~Saurav
 
 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]

This patch was originally posted to silence two GCC warnings while
building v3.6-rc7. Basically identical warnings can still be seen while
building v3.8-rc5. What's the status of this patch?


Paul Bolle

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] qla2xxx: silence two GCC warnings

2012-10-08 Thread Saurav Kashyap

Acked-by: Saurav Kashyap saurav.kash...@qlogic.com

Thanks,
~Saurav

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 pebo...@tiscali.nl
---
0) Updated for Saurav's request to use strncpy().

1) Still only compile tested.

 drivers/scsi/qla2xxx/qla_def.h | 1 +
 drivers/scsi/qla2xxx/qla_gs.c  | 8 
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h
b/drivers/scsi/qla2xxx/qla_def.h
index 39007f5..8895038 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -37,6 +37,7 @@
 #include qla_nx.h
 #define QLA2XXX_DRIVER_NAME   qla2xxx
 #define QLA2XXX_APIDEVql2xapidev
+#define QLA2XXX_MANUFACTURER  QLogic Corporation

 /*
  * 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 05260d2..824cbcf 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1325,8 +1325,8 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
   /* Manufacturer. */
   eiter = (struct ct_fdmi_hba_attr *) (entries + size);
   eiter-type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER);
-  strcpy(eiter-a.manufacturer, QLogic Corporation);
-  alen = strlen(eiter-a.manufacturer);
+  alen = strlen(QLA2XXX_MANUFACTURER);
+  strncpy(eiter-a.manufacturer, QLA2XXX_MANUFACTURER, alen + 1);
   alen += (alen  3) ? (4 - (alen  3)) : 4;
   eiter-len = cpu_to_be16(4 + alen);
   size += 4 + alen;
@@ -1646,8 +1646,8 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
   /* OS device name. */
   eiter = (struct ct_fdmi_port_attr *) (entries + size);
   eiter-type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
-  strcpy(eiter-a.os_dev_name, QLA2XXX_DRIVER_NAME);
-  alen = strlen(eiter-a.os_dev_name);
+  alen = strlen(QLA2XXX_DRIVER_NAME);
+  strncpy(eiter-a.os_dev_name, QLA2XXX_DRIVER_NAME, alen + 1);
   alen += (alen  3) ? (4 - (alen  3)) : 4;
   eiter-len = cpu_to_be16(4 + alen);
   size += 4 + alen;
--
1.7.11.4




This message and any attached documents contain information from QLogic 
Corporation or its wholly-owned subsidiaries that may be confidential. If you 
are not the intended recipient, you may not read, copy, distribute, or use this 
information. If you have received this transmission in error, please notify the 
sender immediately by reply e-mail and then delete this message.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] qla2xxx: silence two GCC warnings

2012-10-05 Thread 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.)

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 pebo...@tiscali.nl
---
0) Updated for Saurav's request to use strncpy().

1) Still only compile tested.

 drivers/scsi/qla2xxx/qla_def.h | 1 +
 drivers/scsi/qla2xxx/qla_gs.c  | 8 
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 39007f5..8895038 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -37,6 +37,7 @@
 #include qla_nx.h
 #define QLA2XXX_DRIVER_NAMEqla2xxx
 #define QLA2XXX_APIDEV ql2xapidev
+#define QLA2XXX_MANUFACTURER   QLogic Corporation
 
 /*
  * 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 05260d2..824cbcf 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1325,8 +1325,8 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
/* Manufacturer. */
eiter = (struct ct_fdmi_hba_attr *) (entries + size);
eiter-type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER);
-   strcpy(eiter-a.manufacturer, QLogic Corporation);
-   alen = strlen(eiter-a.manufacturer);
+   alen = strlen(QLA2XXX_MANUFACTURER);
+   strncpy(eiter-a.manufacturer, QLA2XXX_MANUFACTURER, alen + 1);
alen += (alen  3) ? (4 - (alen  3)) : 4;
eiter-len = cpu_to_be16(4 + alen);
size += 4 + alen;
@@ -1646,8 +1646,8 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
/* OS device name. */
eiter = (struct ct_fdmi_port_attr *) (entries + size);
eiter-type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
-   strcpy(eiter-a.os_dev_name, QLA2XXX_DRIVER_NAME);
-   alen = strlen(eiter-a.os_dev_name);
+   alen = strlen(QLA2XXX_DRIVER_NAME);
+   strncpy(eiter-a.os_dev_name, QLA2XXX_DRIVER_NAME, alen + 1);
alen += (alen  3) ? (4 - (alen  3)) : 4;
eiter-len = cpu_to_be16(4 + alen);
size += 4 + alen;
-- 
1.7.11.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html