mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-10 23:40:12 +00:00
apps/nshlib: replace CONFIG_NSH_LINELEN to LINE_MAX
LINE_MAX: https://github.com/apache/nuttx/pull/15344 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
66231194be
commit
26173597a9
9 changed files with 17 additions and 24 deletions
|
|
@ -379,12 +379,6 @@
|
|||
# define NSH_HERRNO_OF(err) (err)
|
||||
#endif
|
||||
|
||||
/* Maximum size of one command line (telnet or serial) */
|
||||
|
||||
#ifndef CONFIG_NSH_LINELEN
|
||||
# define CONFIG_NSH_LINELEN LINE_MAX
|
||||
#endif
|
||||
|
||||
/* The maximum number of nested if-then[-else]-fi sequences that
|
||||
* are permissible.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ struct console_stdio_s
|
|||
|
||||
/* Line input buffer */
|
||||
|
||||
char cn_line[CONFIG_NSH_LINELEN];
|
||||
char cn_line[LINE_MAX];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||
|
||||
/* readline() returns EOF on failure */
|
||||
|
||||
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
||||
ret = readline_fd(pstate->cn_line, LINE_MAX,
|
||||
INFD(pstate), OUTFD(pstate));
|
||||
if (ret != EOF)
|
||||
{
|
||||
|
|
@ -209,8 +209,7 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||
}
|
||||
|
||||
password[0] = '\0';
|
||||
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
||||
INFD(pstate), -1);
|
||||
ret = readline_fd(pstate->cn_line, LINE_MAX, INFD(pstate), -1);
|
||||
|
||||
/* Enable echo again after password */
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@ int cmd_free(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||
|
||||
int cmd_memdump(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
{
|
||||
char arg[CONFIG_NSH_LINELEN] = "";
|
||||
char arg[LINE_MAX] = "";
|
||||
int i;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
strlcpy(arg, "used", CONFIG_NSH_LINELEN);
|
||||
strlcpy(arg, "used", LINE_MAX);
|
||||
}
|
||||
else if (argc >= 2 && (strcmp(argv[1], "-h") == 0 ||
|
||||
strcmp(argv[1], "help") == 0))
|
||||
|
|
@ -75,10 +75,10 @@ int cmd_memdump(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
strlcat(arg, argv[i], CONFIG_NSH_LINELEN);
|
||||
strlcat(arg, argv[i], LINE_MAX);
|
||||
if (i < argc - 1)
|
||||
{
|
||||
strlcat(arg, " ", CONFIG_NSH_LINELEN);
|
||||
strlcat(arg, " ", LINE_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl,
|
|||
{
|
||||
FAR char *sh_argv[4];
|
||||
FAR char *sh_cmd = "sh";
|
||||
char sh_arg2[CONFIG_NSH_LINELEN];
|
||||
char sh_arg2[LINE_MAX];
|
||||
|
||||
DEBUGASSERT(strncmp(argv[0], sh_cmd, 3) != 0);
|
||||
|
||||
|
|
@ -2462,7 +2462,7 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
|
||||
char tracebuf[CONFIG_NSH_LINELEN + 1];
|
||||
char tracebuf[LINE_MAX + 1];
|
||||
|
||||
strlcpy(tracebuf, cmdline, sizeof(tracebuf));
|
||||
sched_note_beginex(NOTE_TAG_APP, tracebuf);
|
||||
|
|
@ -2685,7 +2685,7 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
|
|||
{
|
||||
FAR char *arg;
|
||||
FAR char *sh_argv[4];
|
||||
char sh_arg2[CONFIG_NSH_LINELEN];
|
||||
char sh_arg2[LINE_MAX];
|
||||
|
||||
if (argv[argc][g_pipeline1_len])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
|||
|
||||
/* Now read the next line from the script file */
|
||||
|
||||
ret = readline_fd(buffer, CONFIG_NSH_LINELEN, vtbl->np.np_fd, -1);
|
||||
ret = readline_fd(buffer, LINE_MAX, vtbl->np.np_fd, -1);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Parse process the command. NOTE: this is recursive...
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ int nsh_session(FAR struct console_stdio_s *pstate,
|
|||
* occurs. Either will cause the session to terminate.
|
||||
*/
|
||||
|
||||
ret = cle_fd(pstate->cn_line, nsh_prompt(), CONFIG_NSH_LINELEN,
|
||||
ret = cle_fd(pstate->cn_line, nsh_prompt(), LINE_MAX,
|
||||
INFD(pstate), OUTFD(pstate));
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ int nsh_session(FAR struct console_stdio_s *pstate,
|
|||
* will cause the session to terminate.
|
||||
*/
|
||||
|
||||
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
||||
ret = readline_fd(pstate->cn_line, LINE_MAX,
|
||||
INFD(pstate), OUTFD(pstate));
|
||||
if (ret == EOF)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
|||
write(OUTFD(pstate), g_userprompt, strlen(g_userprompt));
|
||||
|
||||
username[0] = '\0';
|
||||
if (readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
||||
if (readline_fd(pstate->cn_line, LINE_MAX,
|
||||
INFD(pstate), OUTFD(pstate)) >= 0)
|
||||
|
||||
{
|
||||
|
|
@ -214,7 +214,7 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
|||
}
|
||||
|
||||
password[0] = '\0';
|
||||
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
||||
ret = readline_fd(pstate->cn_line, LINE_MAX,
|
||||
INFD(pstate), OUTFD(pstate));
|
||||
|
||||
/* Enable echo again after password */
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ int cmd_timedatectl(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||
#ifndef CONFIG_NSH_DISABLE_WATCH
|
||||
int cmd_watch(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
{
|
||||
char buffer[CONFIG_NSH_LINELEN];
|
||||
char buffer[LINE_MAX];
|
||||
int interval = 2;
|
||||
int count = -1;
|
||||
FAR char *cmd;
|
||||
|
|
@ -595,7 +595,7 @@ int cmd_watch(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
strlcpy(buffer, cmd, CONFIG_NSH_LINELEN);
|
||||
strlcpy(buffer, cmd, LINE_MAX);
|
||||
ret = nsh_parse(vtbl, buffer);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue