lkml.org 
[lkml]   [2009]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] hvsi: Keep index within state_names[]
Keep index within state_names[]

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
> Hmm, using "hp->state" before the check is somewhat disturbing.

Ok. How about this?

diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 2989056..cacb8c3 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -194,10 +194,12 @@ static inline void print_state(struct hvsi_struct *hp)
"HVSI_WAIT_FOR_MCTRL_RESPONSE",
"HVSI_FSP_DIED",
};
- const char *name = state_names[hp->state];
+ const char *name;

- if (hp->state > ARRAY_SIZE(state_names))
+ if (hp->state >= ARRAY_SIZE(state_names))
name = "UNKNOWN";
+ else
+ name = state_names[hp->state];

pr_debug("hvsi%i: state = %s\n", hp->index, name);
#endif /* DEBUG */

\
 
 \ /
  Last update: 2009-07-13 13:41    [W:0.263 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site