scsi: isci: avoid array subscript warning

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>
This commit is contained in:
Arnd Bergmann 2016-11-18 17:14:01 +01:00 committed by Martin K. Petersen
parent ce41b41e19
commit 5cfa2a3c73
1 changed files with 3 additions and 0 deletions

View File

@ -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