提交 5cfa2a3c 编写于 作者: A Arnd Bergmann 提交者: Martin K. Petersen

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: NArnd Bergmann <arnd@arndb.de>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 ce41b41e
...@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state) ...@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
{ {
static const char * const strings[] = RNC_STATES; static const char * const strings[] = RNC_STATES;
if (state >= ARRAY_SIZE(strings))
return "UNKNOWN";
return strings[state]; return strings[state];
} }
#undef C #undef C
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册