diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 626431b4cae..444e953dddd 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -91,6 +91,7 @@ config SHELL_PRINTF_BUFF_SIZE config SHELL_DEFAULT_TERMINAL_WIDTH int "Default terminal width" + range 1 $(UINT16_MAX) default 80 help Default terminal width is used to break lines. diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 2f36a1b60b7..0032fed7f78 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -141,6 +141,7 @@ static void tab_item_print(const struct shell *sh, const char *option, columns = (sh->ctx->vt100_ctx.cons.terminal_wid - z_shell_strlen(tab)) / longest_option; + __ASSERT_NO_MSG(columns != 0); diff = longest_option - z_shell_strlen(option); if (sh->ctx->vt100_ctx.printed_cmd++ % columns == 0U) { diff --git a/subsys/shell/shell_cmds.c b/subsys/shell/shell_cmds.c index b1a29799a88..ef82c2b1c68 100644 --- a/subsys/shell/shell_cmds.c +++ b/subsys/shell/shell_cmds.c @@ -69,9 +69,6 @@ /* 10 == {esc, [, 2, 5, 0, ;, 2, 5, 0, '\0'} */ #define SHELL_CURSOR_POSITION_BUFFER (10u) -#define SHELL_DEFAULT_TERMINAL_WIDTH 80 -#define SHELL_DEFAULT_TERMINAL_HEIGHT 24 - /* Function reads cursor position from terminal. */ static int cursor_position_get(const struct shell *sh, uint16_t *x, uint16_t *y) { @@ -408,8 +405,8 @@ static int cmd_resize_default(const struct shell *sh, ARG_UNUSED(argv); Z_SHELL_VT100_CMD(sh, SHELL_VT100_SETCOL_80); - sh->ctx->vt100_ctx.cons.terminal_wid = SHELL_DEFAULT_TERMINAL_WIDTH; - sh->ctx->vt100_ctx.cons.terminal_hei = SHELL_DEFAULT_TERMINAL_HEIGHT; + sh->ctx->vt100_ctx.cons.terminal_wid = CONFIG_SHELL_DEFAULT_TERMINAL_WIDTH; + sh->ctx->vt100_ctx.cons.terminal_hei = CONFIG_SHELL_DEFAULT_TERMINAL_HEIGHT; return 0; }