From 207c5cd20c15244b7747cacf45b8dc1fd27deaa4 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Thu, 13 Oct 2011 10:59:07 -0300 Subject: [PATCH] runstate: Print state transition when invalid Makes it easier to debug. Signed-off-by: Luiz Capitulino --- vl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 2dce3ae51..2a634a7ce 100644 --- a/vl.c +++ b/vl.c @@ -393,9 +393,12 @@ void runstate_init(void) /* This function will abort() on invalid state transitions */ void runstate_set(RunState new_state) { - if (new_state >= RUN_STATE_MAX || - !runstate_valid_transitions[current_run_state][new_state]) { - fprintf(stderr, "invalid runstate transition\n"); + assert(new_state < RUN_STATE_MAX); + + if (!runstate_valid_transitions[current_run_state][new_state]) { + fprintf(stderr, "ERROR: invalid runstate transition: '%s' -> '%s'\n", + RunState_lookup[current_run_state], + RunState_lookup[new_state]); abort(); }