diff mbox

[02/10] opensm/console: protect against 0 entered for the perfmgr sweep_time

Message ID 20120703165250.2285498d.weiny2@llnl.gov (mailing list archive)
State Accepted
Delegated to: Alex Netes
Headers show

Commit Message

Ira Weiny July 3, 2012, 11:52 p.m. UTC
The config file already has a check for 0.  This adds the same check to the
console "perfmgr sweep_time" command.

Signed-off-by: Ira Weiny <weiny2@llnl.gov>
---
 opensm/osm_console.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_console.c b/opensm/osm_console.c
index ad3a4d7..5b602d1 100644
--- a/opensm/osm_console.c
+++ b/opensm/osm_console.c
@@ -1471,11 +1471,20 @@  static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 			p_cmd = next_token(p_last);
 			if (p_cmd) {
 				uint16_t time_s = atoi(p_cmd);
-				osm_perfmgr_set_sweep_time_s(&p_osm->perfmgr,
-							     time_s);
+				if (time_s < 1)
+					fprintf(out,
+						"sweep_time requires a "
+						"positive time period "
+						"(in seconds) to be "
+						"specified\n");
+				else
+					osm_perfmgr_set_sweep_time_s(
+							&p_osm->perfmgr,
+							time_s);
 			} else {
 				fprintf(out,
-					"sweep_time requires a time period (in seconds) to be specified\n");
+					"sweep_time requires a time period "
+					"(in seconds) to be specified\n");
 			}
 		} else {
 			fprintf(out, "\"%s\" option not found\n", p_cmd);