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:
wangjianyu3
2025-01-14 10:55:27 +08:00
committed by Xiang Xiao
parent 8cd691c428
commit d04dca42c4
9 changed files with 17 additions and 24 deletions

View File

@@ -377,12 +377,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.
*/

View File

@@ -180,7 +180,7 @@ struct console_stdio_s
/* Line input buffer */
char cn_line[CONFIG_NSH_LINELEN];
char cn_line[LINE_MAX];
};
/****************************************************************************

View File

@@ -171,7 +171,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)
{
@@ -207,8 +207,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 */

View File

@@ -56,12 +56,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))
@@ -73,10 +73,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);
}
}
}

View File

@@ -603,7 +603,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);
@@ -2454,7 +2454,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);
@@ -2677,7 +2677,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])
{

View File

@@ -161,7 +161,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...

View File

@@ -207,7 +207,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 == EOF)
{
@@ -226,7 +226,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)
{

View File

@@ -176,7 +176,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)
{
@@ -212,7 +212,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 */

View File

@@ -550,7 +550,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;
@@ -593,7 +593,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)
{