All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] Display all P-states in HTML-report
Date: Thu, 12 Jul 2012 03:54:01 +0300	[thread overview]
Message-ID: <20120712005401.GA3311@swordfish.datadirect.datadirectnet.com> (raw)
In-Reply-To: 4FFD3BE0.9090803@samsung.com

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

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

             reply	other threads:[~2012-07-12  0:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12  0:54 Sergey Senozhatsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-07-17 22:08 [Powertop] Display all P-states in HTML-report Chris Ferron
2012-07-12  0:57 Sergey Senozhatsky
2012-07-11  8:40 Igor Zhbanov
2012-07-11  6:13 Igor Zhbanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120712005401.GA3311@swordfish.datadirect.datadirectnet.com \
    --to=powertop@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.