hvsi: Keep index within state_names[]
PATCH 1/1 hvsi: Keep index within state_names[]
Keep index within state_names[]
Signed-off-by Roel Kluin <[email protected]>
---
drivers/char/hvsi.c +1 -1
@@ -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);
Keep index within state_names[]
Signed-off-by Roel Kluin <[email protected]>
---
Quoted 1 line
Hmm, using "
hp->state" before the check is somewhat disturbing.
Ok. How about this?
drivers/char/hvsi.c +4 -2
@@ -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 */