iscsi_top: restore old delay value if scanf fails
Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I27d8565296e6c1e94cadaa47c0dfd2cea31f7236
This commit is contained in:
parent
031937d0ff
commit
d35443d460
@ -136,7 +136,7 @@ int main(int argc, char **argv)
|
|||||||
struct spdk_trace_history *history;
|
struct spdk_trace_history *history;
|
||||||
|
|
||||||
uint64_t tasks_done, last_tasks_done[SPDK_TRACE_MAX_LCORE];
|
uint64_t tasks_done, last_tasks_done[SPDK_TRACE_MAX_LCORE];
|
||||||
int delay, history_fd, i, quit, rc;
|
int delay, old_delay, history_fd, i, quit, rc;
|
||||||
int tasks_done_delta, tasks_done_per_sec;
|
int tasks_done_delta, tasks_done_per_sec;
|
||||||
int total_tasks_done_per_sec;
|
int total_tasks_done_per_sec;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
@ -207,9 +207,11 @@ int main(int argc, char **argv)
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
printf("Enter num seconds to delay (1-10): ");
|
printf("Enter num seconds to delay (1-10): ");
|
||||||
|
old_delay = delay;
|
||||||
rc = scanf("%d", &delay);
|
rc = scanf("%d", &delay);
|
||||||
if (rc != 1) {
|
if (rc != 1) {
|
||||||
break;
|
fprintf(stderr, "Illegal delay value\n");
|
||||||
|
delay = old_delay;
|
||||||
} else if (delay < 1 || delay > 10) {
|
} else if (delay < 1 || delay > 10) {
|
||||||
delay = 1;
|
delay = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user