Re: [PATCH][RFC] tools/power turbostat: if --max_loop, print for specific time of loops
From: Yu Chen
Date: Tue Apr 10 2018 - 08:56:59 EST
Hi,
On Tue, Apr 10, 2018 at 07:02:22PM +0800, Bityutskiy, Artem wrote:
> On Tue, 2018-04-10 at 18:18 +0800, Yu Chen wrote:
> > @@ -5076,6 +5084,15 @@ void cmdline(int argc, char **argv)
> > print_version();
> > exit(0);
> > break;
> > + case 'x':
> > + {
> > + unsigned int loops = strtod(optarg, NULL);
>
> It would make sense to error out here if you get a value <= 0.
>
OK.
> > +
> > + if (loops % 2)
> > + loops++;
>
> What is this for?
>
It was intended to make the number of loops even for simplify.
But after rethink about this, it might not be necessary. I'll
change it.
> > + max_loops = loops;
>
> Is the "loops" variable really needed? Can you strtod directly to
> max_loops?
If the sanity check for user input is added then I think the local
variable is needed.
Thanks,
Yu
>
> --
> Best Regards,
> Artem Bityutskiy