From 04ccc79134d7752b97a36cb922d56c9d450983f9 Mon Sep 17 00:00:00 2001 From: Sascha Bischoff Date: Thu, 30 May 2013 12:54:07 -0400 Subject: [PATCH] cpu: Fix bug when reading in TrafficGen state transitions This patch fixes a bug with the traffic generator which occured when reading in the state transitions from the configuration file. Previously, the size of the vector which stored the transitions was used to get the size of the transitions matrix, rather than using the number of states. Therefore, if there were more transitions than states, i.e. some transitions has a probability of less than 1, then the traffic generator would fatal when trying to check the transitions. This issue has been addressed by using the number of input states, rather then the number of transitions. --- src/cpu/testers/traffic_gen/traffic_gen.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpu/testers/traffic_gen/traffic_gen.cc b/src/cpu/testers/traffic_gen/traffic_gen.cc index f5835f8f4..cb2e6e7bb 100644 --- a/src/cpu/testers/traffic_gen/traffic_gen.cc +++ b/src/cpu/testers/traffic_gen/traffic_gen.cc @@ -315,9 +315,9 @@ TrafficGen::parseConfig() } // resize and populate state transition matrix - transitionMatrix.resize(transitions.size()); - for (size_t i = 0; i < transitions.size(); i++) { - transitionMatrix[i].resize(transitions.size()); + transitionMatrix.resize(states.size()); + for (size_t i = 0; i < states.size(); i++) { + transitionMatrix[i].resize(states.size()); } for (vector::iterator t = transitions.begin(); @@ -327,9 +327,9 @@ TrafficGen::parseConfig() // ensure the egress edges do not have a probability larger than // one - for (size_t i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < states.size(); i++) { double sum = 0; - for (size_t j = 0; j < transitions.size(); j++) { + for (size_t j = 0; j < states.size(); j++) { sum += transitionMatrix[i][j]; } -- 2.30.2