avoid integer overflow for usleep() arg

This commit is contained in:
albert 2006-06-17 04:52:42 +00:00
parent 5c591b836f
commit d4a9781d4a
2 changed files with 5 additions and 2 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ top: document H option -- thanks Tony Ernst
top: terabytes -- thanks Tony Ernst
ps: SCHED_BATCH is B
ps: fix s format (signals) output with thread display
watch: avoid integer overflow for the time delay
procps-3.2.5 --> procps-3.2.6

View File

@ -141,7 +141,7 @@ main(int argc, char *argv[])
int option_differences = 0,
option_differences_cumulative = 0,
option_help = 0, option_version = 0;
float interval = 2;
double interval = 2;
char *command;
int command_length = 0; /* not including final \0 */
@ -165,11 +165,13 @@ main(int argc, char *argv[])
case 'n':
{
char *str;
interval = strtof(optarg, &str);
interval = strtod(optarg, &str);
if (!*optarg || *str)
do_usage();
if(interval < 0.1)
interval = 0.1;
if(interval > ~0u/1000000)
interval = ~0u/1000000;
}
break;
case 'v':