From: Arnd Bergmann Date: Fri, 18 Nov 2016 16:14:01 +0000 (+0100) Subject: scsi: isci: avoid array subscript warning X-Git-Tag: v5.15~12285^2~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cfa2a3c7342bd0b50716c8bb32ee491af43c785;p=platform%2Fkernel%2Flinux-starfive.git 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 Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c index 30bd800..e3f2a53 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