On Tue, 17 Feb 2015 09:40:11 -0600 Clark Williams <clark.willi...@gmail.com> wrote: > On Tue, 17 Feb 2015 15:08:38 +0100 Sebastian Andrzej Siewior > <bige...@linutronix.de> wrote: > > * Boris Egorov | 2014-11-27 16:20:34 [+0600]: > > > > >Program will crash if nr_runs is 0 due to dividing by it in > > >print_results(). Let's exit early instead. > > > > > >Fixes: http://bugs.debian.org/716237 > > > > Has this been dealt with? I can't see this applied. I would prefer > > doing the value check in parse_options() itself. And looking at it, it > > seems that run_interval is interval ignored. Or is there macro magic > > invovled? > > > > It looks to me like interval is being ignored in favor of INTERVAL, > which is a macro defined as: > > #define INTERVAL ms2nano(100ULL) > > I think the fix is to change the lines that initialize intv in main() > to use interval rather than INTERVAL. > > Clark
What do you guys think of this patch (moved the check to the bottom of parse_options()): diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c index e3c7a0991ac5..3e4e19e1aec9 100644 --- a/src/rt-migrate-test/rt-migrate-test.c +++ b/src/rt-migrate-test/rt-migrate-test.c @@ -227,6 +227,16 @@ static void parse_options (int argc, char *argv[]) } } + /* sanity check the options */ + if (nr_runs <= 0) { + fprintf(stderr, "Error: --loops argument is non-positive. Exiting.\n"); + exit(-1); + } + + if (prio_start < 1 || prio_start > 99) { + fprintf(stderr, "Error: invalid value for --prio option: %d (valid: 1-99)\n", prio_start); + exit(-1); + } } static unsigned long long get_time(void)
pgpo4dS03oxTF.pgp
Description: OpenPGP digital signature