All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Bernd Petrovitsch <bernd@firmix.at>
Subject: Re: [PATCH] hvsi: Keep index within state_names[]
Date: Mon, 13 Jul 2009 13:39:22 +0200	[thread overview]
Message-ID: <4A5B1CEA.4070806@gmail.com> (raw)
In-Reply-To: <4A5A748D.1000109@gmail.com>

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 */

      reply	other threads:[~2009-07-13 11:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-12 23:41 [PATCH] hvsi: Keep index within state_names[] Roel Kluin
2009-07-13 11:39 ` Roel Kluin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A5B1CEA.4070806@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bernd@firmix.at \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.