On 07/13/2012 11:32 AM, Michal Privoznik wrote:
On 13.07.2012 09:50, Viktor Mihajlovski wrote:
> Fix for a minor issue:
> the sleep(1) statement was called twice,
> effectively doubling the elapsed time
> execution "virsh nodecpustats --percent".
>
> Signed-off-by: Viktor Mihajlovski<mihajlov(a)linux.vnet.ibm.com>
> ---
> tools/virsh.c | 11 +++++------
> 1 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 01e7ce0..767e2fc 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -6840,8 +6840,10 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
> memset(cpu_stats, 0, sizeof(cpu_stats));
> params = vshCalloc(ctl, nparams, sizeof(*params));
>
> - i = 0;
> - do {
> + for (i=0; i<2; i++) {
We keep spaces around operators (except increment, decrement and unary minus). So this
should be:
for (i = 0; i< 2; i++) {
and so forth.
> + if (i>0)
> + sleep(1);
> +
> if (virNodeGetCPUStats(ctl->conn, cpuNum, params,&nparams, 0) != 0)
{
> vshError(ctl, "%s", _("Unable to get node cpu
stats"));
> goto cleanup;
> @@ -6866,10 +6868,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
>
> if (flag_utilization || !flag_percent)
> break;
> -
> - i++;
> - sleep(1);
> - } while (i< 2);
> + }
>
> if (!flag_percent) {
> if (!flag_utilization) {
>
However, fixed, ACKed and pushed:
diff --git a/tools/virsh.c b/tools/virsh.c
index c103e24..f9fe4b1 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6840,8 +6840,8 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
memset(cpu_stats, 0, sizeof(cpu_stats));
params = vshCalloc(ctl, nparams, sizeof(*params));
- for (i=0; i<2; i++) {
- if (i>0)
+ for (i = 0; i< 2; i++) {
+ if (i> 0)
sleep(1);
if (virNodeGetCPUStats(ctl->conn, cpuNum, params,&nparams, 0) != 0) {
Michal
Hi Michal,
thanks (once more) for fixing up my patch. The missing spaces escaped me
when doing the up-front review, which is kind of embarrassing.
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294