* [PATCH] isci: avoid array subscript warning
@ 2016-11-18 16:14 Arnd Bergmann
2016-11-29 16:46 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-11-18 16:14 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen
Cc: Arnd Bergmann, Intel SCU Linux support, Artur Paszkiewicz,
Bart Van Assche, Colin Ian King, linux-scsi, linux-kernel
I'm getting a new warning with gcc-7:
isci/remote_node_context.c: In function 'sci_remote_node_context_destruct':
isci/remote_node_context.c:69:16: error: array subscript is above array bounds [-Werror=array-bounds]
This is odd, since we clearly cover all values for enum
scis_sds_remote_node_context_states here. Anyway, checking
for an array overflow can't harm and it makes the warning
go away.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/scsi/isci/remote_node_context.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 30bd80052e03..e3f2a5359d71 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
{
static const char * const strings[] = RNC_STATES;
+ if (state >= ARRAY_SIZE(strings))
+ return "UNKNOWN";
+
return strings[state];
}
#undef C
--
2.9.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] isci: avoid array subscript warning
2016-11-18 16:14 [PATCH] isci: avoid array subscript warning Arnd Bergmann
@ 2016-11-29 16:46 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2016-11-29 16:46 UTC (permalink / raw)
To: Arnd Bergmann
Cc: James E.J. Bottomley, Martin K. Petersen,
Intel SCU Linux support, Artur Paszkiewicz, Bart Van Assche,
Colin Ian King, linux-scsi, linux-kernel
>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:
Arnd> I'm getting a new warning with gcc-7: isci/remote_node_context.c:
Arnd> In function 'sci_remote_node_context_destruct':
Arnd> isci/remote_node_context.c:69:16: error: array subscript is above
Arnd> array bounds [-Werror=array-bounds]
Applied to 4.10/scsi-queue.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-29 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-18 16:14 [PATCH] isci: avoid array subscript warning Arnd Bergmann
2016-11-29 16:46 ` Martin K. Petersen
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®