Skip to content

Commit da8477a

Browse files
arndbgregkh
authored andcommitted
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>
1 parent 717bd21 commit da8477a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/scsi/isci/remote_node_context.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
6666
{
6767
static const char * const strings[] = RNC_STATES;
6868

69+
if (state >= ARRAY_SIZE(strings))
70+
return "UNKNOWN";
71+
6972
return strings[state];
7073
}
7174
#undef C

0 commit comments

Comments
 (0)