[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4A5B1CEA.4070806@gmail.com>
Date: Mon, 13 Jul 2009 13:39:22 +0200
From: Roel Kluin <roel.kluin@...il.com>
To: Roel Kluin <roel.kluin@...il.com>
CC: Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Bernd Petrovitsch <bernd@...mix.at>
Subject: Re: [PATCH] hvsi: Keep index within state_names[]
Keep index within state_names[]
Signed-off-by: Roel Kluin <roel.kluin@...il.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 */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists