From 66231194be3de611c18bfaa2e63eece604184041 Mon Sep 17 00:00:00 2001 From: chao an Date: Fri, 27 Dec 2024 14:20:37 +0800 Subject: [PATCH] apps/system: replace CONFIG_NSH_LINELEN to LINE_MAX Applications should not depend on any properties of nshlib Signed-off-by: chao an --- examples/lp503x/lp503x_main.c | 2 +- netutils/rexec/rexec.c | 2 +- nshlib/nsh.h | 2 +- system/nxcamera/nxcamera_main.c | 2 +- system/nxlooper/nxlooper_main.c | 2 +- system/nxplayer/nxplayer_main.c | 2 +- system/nxrecorder/nxrecorder_main.c | 2 +- system/readline/readline.c | 14 ++------------ system/taskset/taskset.c | 4 ++-- system/trace/trace.c | 2 +- 10 files changed, 12 insertions(+), 22 deletions(-) diff --git a/examples/lp503x/lp503x_main.c b/examples/lp503x/lp503x_main.c index 2d34929a6..4ab99803f 100644 --- a/examples/lp503x/lp503x_main.c +++ b/examples/lp503x/lp503x_main.c @@ -626,7 +626,7 @@ static int lp503x_cmd_help(FAR char *parg) int main(int argc, FAR char *argv[]) { bool running; - char buffer[CONFIG_NSH_LINELEN]; + char buffer[LINE_MAX]; int len; int x; char *cmd; diff --git a/netutils/rexec/rexec.c b/netutils/rexec/rexec.c index 3276ac56a..01c8000bf 100644 --- a/netutils/rexec/rexec.c +++ b/netutils/rexec/rexec.c @@ -155,7 +155,7 @@ static int do_rexec(FAR struct rexec_arg_s *arg) int main(int argc, FAR char **argv) { - char cmd[CONFIG_NSH_LINELEN]; + char cmd[LINE_MAX]; struct rexec_arg_s arg; int option; int i; diff --git a/nshlib/nsh.h b/nshlib/nsh.h index ef33088ac..f040e0b16 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -382,7 +382,7 @@ /* Maximum size of one command line (telnet or serial) */ #ifndef CONFIG_NSH_LINELEN -# define CONFIG_NSH_LINELEN 80 +# define CONFIG_NSH_LINELEN LINE_MAX #endif /* The maximum number of nested if-then[-else]-fi sequences that diff --git a/system/nxcamera/nxcamera_main.c b/system/nxcamera/nxcamera_main.c index c5fd52d9e..754f12e1d 100644 --- a/system/nxcamera/nxcamera_main.c +++ b/system/nxcamera/nxcamera_main.c @@ -398,7 +398,7 @@ static int nxcamera_cmd_help(FAR struct nxcamera_s *pcam, FAR char *parg) int main(int argc, FAR char *argv[]) { - char buffer[CONFIG_NSH_LINELEN]; + char buffer[LINE_MAX]; int len; int x; bool running = true; diff --git a/system/nxlooper/nxlooper_main.c b/system/nxlooper/nxlooper_main.c index 82a7ec50d..710fb8a77 100644 --- a/system/nxlooper/nxlooper_main.c +++ b/system/nxlooper/nxlooper_main.c @@ -502,7 +502,7 @@ static int nxlooper_cmd_help(FAR struct nxlooper_s *plooper, char *parg) int main(int argc, FAR char *argv[]) { - char buffer[CONFIG_NSH_LINELEN]; + char buffer[LINE_MAX]; int len; int x; int running; diff --git a/system/nxplayer/nxplayer_main.c b/system/nxplayer/nxplayer_main.c index e4869cf64..daeed9477 100644 --- a/system/nxplayer/nxplayer_main.c +++ b/system/nxplayer/nxplayer_main.c @@ -739,7 +739,7 @@ static int nxplayer_cmd_help(FAR struct nxplayer_s *pplayer, char *parg) int main(int argc, FAR char *argv[]) { - char buffer[CONFIG_NSH_LINELEN]; + char buffer[LINE_MAX]; int len; int x; int running; diff --git a/system/nxrecorder/nxrecorder_main.c b/system/nxrecorder/nxrecorder_main.c index 340611696..5b649d532 100644 --- a/system/nxrecorder/nxrecorder_main.c +++ b/system/nxrecorder/nxrecorder_main.c @@ -531,7 +531,7 @@ static int nxrecorder_cmd_help(FAR struct nxrecorder_s *precorder, int main(int argc, FAR char *argv[]) { - char buffer[CONFIG_NSH_LINELEN]; + char buffer[LINE_MAX]; int len; int x; int running; diff --git a/system/readline/readline.c b/system/readline/readline.c index b8032e1ee..f767b0ab2 100644 --- a/system/readline/readline.c +++ b/system/readline/readline.c @@ -32,16 +32,6 @@ #include "system/readline.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Maximum size of one command line (telnet or serial) */ - -#ifndef CONFIG_NSH_LINELEN -# define CONFIG_NSH_LINELEN 80 -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -59,14 +49,14 @@ FAR char *readline(FAR const char *prompt) { - FAR char *line = malloc(CONFIG_NSH_LINELEN); + FAR char *line = malloc(LINE_MAX); if (line != NULL) { #ifdef CONFIG_READLINE_TABCOMPLETION FAR const char *orig = readline_prompt(prompt); #endif - if (readline_fd(line, CONFIG_NSH_LINELEN, + if (readline_fd(line, LINE_MAX, STDIN_FILENO, STDOUT_FILENO) == 0) { free(line); diff --git a/system/taskset/taskset.c b/system/taskset/taskset.c index af74a4076..bae0246a9 100644 --- a/system/taskset/taskset.c +++ b/system/taskset/taskset.c @@ -82,7 +82,7 @@ static bool get_cpuset(const char *arg, cpu_set_t *cpu_set) int main(int argc, FAR char *argv[]) { - char command[CONFIG_NSH_LINELEN]; + char command[LINE_MAX]; int exitcode; int option; int pid = -1; @@ -153,7 +153,7 @@ int main(int argc, FAR char *argv[]) } /* Construct actual command with args - * NOTE: total length does not exceed CONFIG_NSH_LINELEN + * NOTE: total length does not exceed LINE_MAX */ for (i = 0; i < argc - 2; i++) diff --git a/system/trace/trace.c b/system/trace/trace.c index 46126b9e2..f4a5454a4 100644 --- a/system/trace/trace.c +++ b/system/trace/trace.c @@ -229,7 +229,7 @@ static int trace_cmd_dump(FAR const char *name, int index, int argc, static int trace_cmd_cmd(FAR const char *name, int index, int argc, FAR char **argv, int notectlfd) { - char command[CONFIG_NSH_LINELEN]; + char command[LINE_MAX]; bool changed; bool cont = false;