diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-22 15:17:37 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-22 15:17:37 +0000 |
commit | 35d09baa84f3e029646e3a2f2f0e9b348de57517 (patch) | |
tree | 9e108a9d304ab73d8e596b65dae1b83f82b6d095 /cpukit/libmisc/shell/main_msdosfmt.c | |
parent | 2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-35d09baa84f3e029646e3a2f2f0e9b348de57517.tar.bz2 |
2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_chmod.c,
libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c,
libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c,
libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c,
libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c,
libmisc/shell/shell.h, libmisc/shell/shell_script.c,
libmisc/stringto/stringto_template.h: Convert all shell code to use
stringto.h mehods with better error checking.
* libmisc/shell/str2int.c: Removed.
Diffstat (limited to 'cpukit/libmisc/shell/main_msdosfmt.c')
-rw-r--r-- | cpukit/libmisc/shell/main_msdosfmt.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/cpukit/libmisc/shell/main_msdosfmt.c b/cpukit/libmisc/shell/main_msdosfmt.c index 58a116aa3c..d682728b9d 100644 --- a/cpukit/libmisc/shell/main_msdosfmt.c +++ b/cpukit/libmisc/shell/main_msdosfmt.c @@ -1,10 +1,4 @@ /* - * Shell Command Implmentation - * - * Author: Fernando RUIZ CASAS - * Work: fernando.ruiz@ctv.es - * Home: correo@fernando-ruiz.com - * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. @@ -23,6 +17,7 @@ #include <rtems.h> #include <rtems/shell.h> +#include <rtems/stringto.h> #include <rtems/shellconfig.h> #include <rtems/dosfs.h> #include <rtems/fsmount.h> @@ -46,8 +41,9 @@ int rtems_shell_main_msdos_format( info_level: 0 }; - const char* driver = NULL; - int arg; + unsigned long tmp; + const char* driver = NULL; + int arg; for (arg = 1; arg < argc; arg++) { if (argv[arg][0] == '-') { @@ -67,7 +63,16 @@ int rtems_shell_main_msdos_format( fprintf (stderr, "error: sectors per cluster count.\n"); return 1; } - rqdata.sectors_per_cluster = rtems_shell_str2int(argv[arg]); + + if ( !rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) { + printf( + "sector per cluster argument (%s) is not a number\n", + argv[arg] + ); + return -1; + } + + rqdata.sectors_per_cluster = (uint32_t) tmp; break; case 'r': @@ -76,7 +81,16 @@ int rtems_shell_main_msdos_format( fprintf (stderr, "error: no root directory size.\n"); return 1; } - rqdata.files_per_root_dir = rtems_shell_str2int(argv[arg]); + + if ( !rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) { + printf( + "root directory size argument (%s) is not a number\n", + argv[arg] + ); + return -1; + } + + rqdata.files_per_root_dir = (uint32_t) tmp; break; case 't': |