mirror of https://github.com/ipxe/ipxe.git
[cmdline] Fix up "sleep" argument parsing
Use parse_integer() rather than strtoul() to allow parsing errors to be reported in a meaningful way. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/5/head
parent
bf2da3122b
commit
f177a6f09f
|
@ -548,17 +548,25 @@ static struct command_descriptor sleep_cmd =
|
||||||
*/
|
*/
|
||||||
static int sleep_exec ( int argc, char **argv ) {
|
static int sleep_exec ( int argc, char **argv ) {
|
||||||
struct sleep_options opts;
|
struct sleep_options opts;
|
||||||
unsigned long start, delay;
|
unsigned int seconds;
|
||||||
|
unsigned long start;
|
||||||
|
unsigned long delay;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Parse options */
|
/* Parse options */
|
||||||
if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
|
if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
/* Parse number of seconds */
|
||||||
|
if ( ( rc = parse_integer ( argv[optind], &seconds ) ) != 0 )
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
/* Delay for specified number of seconds */
|
||||||
start = currticks();
|
start = currticks();
|
||||||
delay = strtoul ( argv[1], NULL, 0 ) * ticks_per_sec();
|
delay = ( seconds * TICKS_PER_SEC );
|
||||||
while ( ( currticks() - start ) <= delay )
|
while ( ( currticks() - start ) <= delay )
|
||||||
cpu_nap();
|
cpu_nap();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue