[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-rt-users
Subject:    [PATCH] rt-migrate-test: exit early if nr_runs is non-positive
From:       Boris Egorov <egorov () linux ! com>
Date:       2014-11-27 10:20:34
Message-ID: 5476FAF2.1060702 () linux ! com
[Download RAW message or body]

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

Signed-off-by: Boris Egorov <egorov@linux.com>
---
 src/rt-migrate-test/rt-migrate-test.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/rt-migrate-test/rt-migrate-test.c
b/src/rt-migrate-test/rt-migrate-test.c
index e3c7a09..876a122 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -465,6 +465,11 @@ int main (int argc, char **argv)
  	parse_options(argc, argv);
+	if (nr_runs <= 0) {
+		fprintf(stderr, "Warning, --loops argument is non-positive. Exiting.\n");
+		exit(-1);
+	}
+
 	signal(SIGINT, stop_log);
  	if (argc >= (optind + 1))
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic