Re: [Powertop] Display all P-states in HTML-report
Sergey Senozhatsky <sergey.senozhatsky at gmail.com> Thu, 12 Jul 2012 03:54:01 +0300
| Newsgroups | dev.linux.lists.powertop |
|---|---|
| Message-ID | <[email protected]> |
On (07/11/12 12:40), Igor Zhbanov wrote:
>
> + unsigned int i, pstates_num;
> +
> + for (i = 0, pstates_num = 0; i< all_cpus.size(); i++)
> + if (all_cpus[i]&& all_cpus[i]->pstates.size()> pstates_num)
> + pstates_num = all_cpus[i]->pstates.size();
>
nack
That will not work correctly, I'm afraid.
pstates_num initialized with stack garbage and is free to have value (e.g. 0x7fffffff)
which will never satisfy "all_cpus[i]->pstates.size()> pstates_num" condition.
In that case our loop will spin "0x7fffffff - actual_pstates_number" useless cycles.
BTW, could you please put white space before operators and remove extra one after?
E.g.
"all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num"
vs.
"all_cpus[i]&& all_cpus[i]->pstates.size()> pstates_num"
^^^^^^ ^^^^^
-ss