From da6a8c94a8f8124711db0ae84a3ef4e0e186b388 Mon Sep 17 00:00:00 2001 From: Zoran Markovic Date: Wed, 29 Jan 2014 15:47:47 -0800 Subject: Fixing improperly initialized cstate_max per-CPU. --- idlestat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/idlestat.c b/idlestat.c index ab3aaab..3abfaaf 100644 --- a/idlestat.c +++ b/idlestat.c @@ -240,7 +240,7 @@ static int store_data(double time, int state, int cpu, int nrdata, last_cstate = cstates->last_cstate; /* ignore when we got a "closing" state first */ - if (state == -1 && !cstates->cstate_max) + if (state == -1 && cstates->cstate_max == -1) return 0; cstate = &cstates->cstate[state == -1 ? last_cstate : state ]; @@ -398,6 +398,9 @@ static struct cpuidle_datas *idlestat_load(const char *path) datas->cstates = calloc(sizeof(*datas->cstates), nrcpus); if (!datas->cstates) return ptrerror("calloc cstate"); + /* initialize cstate_max for each cpu */ + for (cpu = 0; cpu < nrcpus; cpu++) + datas->cstates[cpu].cstate_max = -1; datas->nrcpus = nrcpus; -- cgit v1.2.3