summaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-11-18 17:14:01 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-09-02 07:05:44 +0200
commit8df251426dae53a74dd6b2d3f02503a2b270c2ef (patch)
treef4721a6a6b85aef1f1e71e6f926a243d501eedf5 /drivers/scsi
parent2713f9f39b8fd713d914c0051b8dc5acf1bc2c6d (diff)
downloadlinux-stable-8df251426dae53a74dd6b2d3f02503a2b270c2ef.tar.gz
linux-stable-8df251426dae53a74dd6b2d3f02503a2b270c2ef.tar.bz2
linux-stable-8df251426dae53a74dd6b2d3f02503a2b270c2ef.zip
scsi: isci: avoid array subscript warning
commit 5cfa2a3c7342bd0b50716c8bb32ee491af43c785 upstream. 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> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/isci/remote_node_context.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 1910100638a2..00602abec0ea 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