Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1525491
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] isci: avoid array subscript warning |
| Date | 2016-11-18 17:20 +0100 |
| Message-ID | <sEU3o-113-41@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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>
---
drivers/scsi/isci/remote_node_context.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 30bd80052e03..e3f2a5359d71 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
--
2.9.0
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] isci: avoid array subscript warning Arnd Bergmann <arnd@arndb.de> - 2016-11-18 17:20 +0100
csiph-web