isci: avoid array subscript warning
Subsystems (2)
PATCH 1/1 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.
--- drivers/scsi/isci/remote_node_context.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/isci/remote_node_context.c +3 -0
@@ -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
Signature · 1 line
2.9.0
Martin K. Petersen
AppliedQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnd" == Arnd Bergmann <[email protected]> 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.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering