* [PATCH] hvsi: Keep index within state_names[]
@ 2009-07-12 23:41 Roel Kluin
2009-07-13 11:39 ` Roel Kluin
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-07-12 23:41 UTC (permalink / raw)
To: Andrew Morton, LKML
Keep index within state_names[]
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 2989056..05dd854 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -196,7 +196,7 @@ static inline void print_state(struct hvsi_struct *hp)
};
const char *name = state_names[hp->state];
- if (hp->state > ARRAY_SIZE(state_names))
+ if (hp->state >= ARRAY_SIZE(state_names))
name = "UNKNOWN";
pr_debug("hvsi%i: state = %s\n", hp->index, name);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hvsi: Keep index within state_names[]
2009-07-12 23:41 [PATCH] hvsi: Keep index within state_names[] Roel Kluin
@ 2009-07-13 11:39 ` Roel Kluin
0 siblings, 0 replies; 2+ messages in thread
From: Roel Kluin @ 2009-07-13 11:39 UTC (permalink / raw)
To: Roel Kluin; +Cc: Andrew Morton, LKML, Bernd Petrovitsch
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 */
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-13 11:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-12 23:41 [PATCH] hvsi: Keep index within state_names[] Roel Kluin
2009-07-13 11:39 ` Roel Kluin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox