diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-08 13:56:21 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-08 13:56:21 +0000 |
commit | 58686d844f7dc2d098fe853ef6b48df850d0822c (patch) | |
tree | 0622029fef5305661e1a27dbc8a8d6b7db1cf79a /apps | |
parent | 5119467c0f090b90cdbff4718c407cbd7d2be905 (diff) | |
download | px4-firmware-58686d844f7dc2d098fe853ef6b48df850d0822c.tar.gz px4-firmware-58686d844f7dc2d098fe853ef6b48df850d0822c.tar.bz2 px4-firmware-58686d844f7dc2d098fe853ef6b48df850d0822c.zip |
Shenzhou board is first to use ONLY Kconfig for configuration
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5114 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/ChangeLog.txt | 4 | ||||
-rw-r--r-- | apps/nshlib/nsh_mntcmds.c | 30 | ||||
-rw-r--r-- | apps/system/readline/Kconfig | 17 | ||||
-rw-r--r-- | apps/system/readline/readline.c | 29 |
4 files changed, 52 insertions, 28 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 6d5f605c7..2ef4b67f9 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -310,3 +310,7 @@ files into memory before transferring them. * apps/netutils/webserver: Add ability to map a URL to CGI function. Contributed by Kate. + * apps/nshlib/nsh_mntcmds.c: The changes of 6.21 introduced holes in the + error handling: Now the number of arguments to mount can be 0 or 4. + Additional parameter checking is required to prevent mysterious errors + (submiteed by Kate). diff --git a/apps/nshlib/nsh_mntcmds.c b/apps/nshlib/nsh_mntcmds.c index b5935bdea..027046c77 100644 --- a/apps/nshlib/nsh_mntcmds.c +++ b/apps/nshlib/nsh_mntcmds.c @@ -195,9 +195,9 @@ int cmd_df(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT) int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { - char *source; - char *target; - char *filesystem = 0; + FAR char *source; + FAR char *target; + FAR char *filesystem = NULL; bool badarg = false; int ret; @@ -208,7 +208,11 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return mount_show(vtbl, argv[0]); } - /* Get the mount options */ + /* Get the mount options. NOTE: getopt() is not thread safe nor re-entrant. + * To keep its state proper for the next usage, it is necessary to parse to + * the end of the line even if an error occurs. If an error occurs, this + * logic just sets 'badarg' and continues. + */ int option; while ((option = getopt(argc, argv, ":t:")) != ERROR) @@ -232,14 +236,18 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, then return without processing the + * command. + */ if (badarg) { return ERROR; } - /* There are two required arguments after the options */ + /* There are two required arguments after the options: the source and target + * paths. + */ if (optind + 2 < argc) { @@ -252,6 +260,16 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ERROR; } + /* While the above parsing for the -t argument looks nice, the -t argument + * not really optional. + */ + + if (!filesystem) + { + nsh_output(vtbl, g_fmtargrequired, argv[0]); + return ERROR; + } + /* The source and target paths might be relative to the current * working directory. */ diff --git a/apps/system/readline/Kconfig b/apps/system/readline/Kconfig index 2ed9cafd6..6482b1204 100644 --- a/apps/system/readline/Kconfig +++ b/apps/system/readline/Kconfig @@ -19,21 +19,4 @@ config READLINE_ECHO already has local echo support or you need to suppress the back-channel responses for any other reason. -choice - prompt "Newline Options" - default EOL_IS_EITHER_CRLF - -config EOL_IS_CR - bool "EOL is CR" - -config EOL_IS_LF - bool "EOL is LF" - -config EOL_IS_BOTH_CRLF - bool "EOL is CR and LF" - -config EOL_IS_EITHER_CRLF - bool "EOL is CR or LF" - -endchoice endif diff --git a/apps/system/readline/readline.c b/apps/system/readline/readline.c index bdd39e67b..ec2dc1c0a 100644 --- a/apps/system/readline/readline.c +++ b/apps/system/readline/readline.c @@ -63,13 +63,32 @@ #define CONFIG_READLINE_ECHO 1 /* Some environments may return CR as end-of-line, others LF, and others - * both. The logic here assumes either but not both. + * both. If not specified, the logic here assumes either (but not both) as + * the default. */ -#undef CONFIG_EOL_IS_CR -#undef CONFIG_EOL_IS_LF -#undef CONFIG_EOL_IS_BOTH_CRLF -#define CONFIG_EOL_IS_EITHER_CRLF 1 +#if defined(CONFIG_EOL_IS_CR) +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_BOTH_CRLF +# undef CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_LF) +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_BOTH_CRLF +# undef CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_BOTH_CRLF) +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_EITHER_CRLF) +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_BOTH_CRLF +#else +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_BOTH_CRLF +# define CONFIG_EOL_IS_EITHER_CRLF 1 +#endif /**************************************************************************** * Private Type Declarations |