All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Egorov <egorov@linux.com>
To: 716237@bugs.debian.org, linux-rt-users@vger.kernel.org
Cc: Boris Egorov <egorov@linux.com>
Subject: [PATCH] rt-migrate-test: exit early if nr_runs is non-positive
Date: Thu, 27 Nov 2014 16:20:34 +0600	[thread overview]
Message-ID: <5476FAF2.1060702@linux.com> (raw)

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


             reply	other threads:[~2014-11-27 10:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27 10:20 Boris Egorov [this message]
2015-02-17 14:08 ` [PATCH] rt-migrate-test: exit early if nr_runs is non-positive Sebastian Andrzej Siewior
2015-02-17 14:30   ` Boris Egorov
2015-02-17 14:35     ` Boris Egorov
2015-02-17 16:51       ` John Kacur
2015-02-17 17:43 ` [PATCH v2 0/2] rt-migrate-test: few sanity fixes Boris Egorov
2015-02-17 17:43   ` [PATCH v2 1/2] rt-migrate-test: exit early if nr_runs is non-positive Boris Egorov
2015-02-17 17:43   ` [PATCH v2 2/2] rt-migrate-test: use variables instead of macros Boris Egorov
2015-02-17 19:27   ` [PATCH v2 0/2] rt-migrate-test: few sanity fixes Clark Williams

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=5476FAF2.1060702@linux.com \
    --to=egorov@linux.com \
    --cc=716237@bugs.debian.org \
    --cc=linux-rt-users@vger.kernel.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.