From 0bfaf775c11e43c8bb15faa4f75177ef4fea382d Mon Sep 17 00:00:00 2001 From: Peter Marcisovsky Date: Mon, 29 Apr 2024 16:12:51 +0200 Subject: [PATCH] refactor(console): Enable astyle formatting --- components/console/commands.c | 34 +++++++++---------- components/console/esp_console.h | 2 +- components/console/esp_console_repl_chip.c | 8 ++--- components/console/esp_console_repl_linux.c | 2 +- .../console/private_include/console_private.h | 4 +-- components/console/split_argv.c | 4 +-- .../test_apps/console/main/test_console.c | 18 +++++----- tools/ci/astyle-rules.yml | 1 - 8 files changed, 36 insertions(+), 37 deletions(-) diff --git a/components/console/commands.c b/components/console/commands.c index c5e1f2035f..e5722c6655 100644 --- a/components/console/commands.c +++ b/components/console/commands.c @@ -250,22 +250,22 @@ static struct { static void print_arg_help(cmd_item_t *it) { - /* First line: command name and hint - * Pad all the hints to the same column - */ - const char *hint = (it->hint) ? it->hint : ""; - printf("%-s %s\n", it->command, hint); - /* Second line: print help. - * Argtable has a nice helper function for this which does line - * wrapping. - */ - printf(" "); // arg_print_formatted does not indent the first line - arg_print_formatted(stdout, 2, 78, it->help); - /* Finally, print the list of arguments */ - if (it->argtable) { - arg_print_glossary(stdout, (void **) it->argtable, " %12s %s\n"); - } - printf("\n"); + /* First line: command name and hint + * Pad all the hints to the same column + */ + const char *hint = (it->hint) ? it->hint : ""; + printf("%-s %s\n", it->command, hint); + /* Second line: print help. + * Argtable has a nice helper function for this which does line + * wrapping. + */ + printf(" "); // arg_print_formatted does not indent the first line + arg_print_formatted(stdout, 2, 78, it->help); + /* Finally, print the list of arguments */ + if (it->argtable) { + arg_print_glossary(stdout, (void **) it->argtable, " %12s %s\n"); + } + printf("\n"); } static int help_command(int argc, char **argv) @@ -322,7 +322,7 @@ esp_err_t esp_console_register_help_command(void) esp_console_cmd_t command = { .command = "help", .help = "Print the summary of all registered commands if no arguments " - "are given, otherwise print summary of given command.", + "are given, otherwise print summary of given command.", .func = &help_command, .argtable = &help_args }; diff --git a/components/console/esp_console.h b/components/console/esp_console.h index 236d6949dc..921300f943 100644 --- a/components/console/esp_console.h +++ b/components/console/esp_console.h @@ -78,7 +78,7 @@ typedef struct { */ typedef struct { int channel; //!< UART channel number (count from zero) - int baud_rate; //!< Comunication baud rate + int baud_rate; //!< Communication baud rate int tx_gpio_num; //!< GPIO number for TX path, -1 means using default one int rx_gpio_num; //!< GPIO number for RX path, -1 means using default one } esp_console_dev_uart_config_t; diff --git a/components/console/esp_console_repl_chip.c b/components/console/esp_console_repl_chip.c index 2bc79bbf54..f0d2f6e002 100644 --- a/components/console/esp_console_repl_chip.c +++ b/components/console/esp_console_repl_chip.c @@ -83,7 +83,7 @@ esp_err_t esp_console_new_repl_usb_cdc(const esp_console_dev_usb_cdc_config_t *d /* spawn a single thread to run REPL */ if (xTaskCreatePinnedToCore(esp_console_repl_task, "console_repl", repl_config->task_stack_size, - cdc_repl, repl_config->task_priority, &cdc_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) { + cdc_repl, repl_config->task_priority, &cdc_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) { ret = ESP_FAIL; goto _exit; } @@ -160,7 +160,7 @@ esp_err_t esp_console_new_repl_usb_serial_jtag(const esp_console_dev_usb_serial_ /* spawn a single thread to run REPL */ if (xTaskCreatePinnedToCore(esp_console_repl_task, "console_repl", repl_config->task_stack_size, - usb_serial_jtag_repl, repl_config->task_priority, &usb_serial_jtag_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) { + usb_serial_jtag_repl, repl_config->task_priority, &usb_serial_jtag_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) { ret = ESP_FAIL; goto _exit; } @@ -217,7 +217,7 @@ esp_err_t esp_console_new_repl_uart(const esp_console_dev_uart_config_t *dev_con #elif SOC_UART_SUPPORT_XTAL_CLK uart_sclk_t clk_source = UART_SCLK_XTAL; #else - #error "No UART clock source is aware of DFS" +#error "No UART clock source is aware of DFS" #endif // SOC_UART_SUPPORT_xxx const uart_config_t uart_config = { .baud_rate = dev_config->baud_rate, @@ -262,7 +262,7 @@ esp_err_t esp_console_new_repl_uart(const esp_console_dev_uart_config_t *dev_con /* Spawn a single thread to run REPL, we need to pass `uart_repl` to it as * it also requires the uart channel. */ if (xTaskCreatePinnedToCore(esp_console_repl_task, "console_repl", repl_config->task_stack_size, - uart_repl, repl_config->task_priority, &uart_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) { + uart_repl, repl_config->task_priority, &uart_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) { ret = ESP_FAIL; goto _exit; } diff --git a/components/console/esp_console_repl_linux.c b/components/console/esp_console_repl_linux.c index a01d2f8134..9a427c9bb8 100644 --- a/components/console/esp_console_repl_linux.c +++ b/components/console/esp_console_repl_linux.c @@ -51,7 +51,7 @@ static void prepare_input_stream(void) assert(tcgetattr(stdin_fileno, &s_orig_termios) == 0); struct termios raw = s_orig_termios; raw.c_iflag |= ICRNL; // we translate to NL because linenoise expects NL - raw.c_lflag &= ~(ECHO | ICANON); // turn off echo and cononical mode + raw.c_lflag &= ~(ECHO | ICANON); // turn off echo and canonical mode assert(tcsetattr(stdin_fileno, TCSAFLUSH, &raw) == 0); // Make sure user does not end up with a broken terminal diff --git a/components/console/private_include/console_private.h b/components/console/private_include/console_private.h index 6f9f8361af..c21144efcb 100644 --- a/components/console/private_include/console_private.h +++ b/components/console/private_include/console_private.h @@ -47,5 +47,5 @@ void esp_console_repl_task(void *args); esp_err_t esp_console_common_init(size_t max_cmdline_length, esp_console_repl_com_t *repl_com); esp_err_t esp_console_setup_prompt(const char *prompt, esp_console_repl_com_t *repl_com); esp_err_t esp_console_setup_history(const char *history_path, - uint32_t max_history_len, - esp_console_repl_com_t *repl_com); + uint32_t max_history_len, + esp_console_repl_com_t *repl_com); diff --git a/components/console/split_argv.c b/components/console/split_argv.c index d2e3bd0846..efaea35355 100644 --- a/components/console/split_argv.c +++ b/components/console/split_argv.c @@ -40,7 +40,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size) char *next_arg_start = line; char *out_ptr = line; for (char *in_ptr = line; argc < argv_size - 1; ++in_ptr) { - int char_in = (unsigned char) *in_ptr; + int char_in = (unsigned char) * in_ptr; if (char_in == 0) { break; } @@ -80,7 +80,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size) } else { /* unrecognized escape character, skip */ } - state = (split_state_t) (state & (~SS_FLAG_ESCAPE)); + state = (split_state_t)(state & (~SS_FLAG_ESCAPE)); break; case SS_ARG: diff --git a/components/console/test_apps/console/main/test_console.c b/components/console/test_apps/console/main/test_console.c index 0b6a7d1b58..4d623f3805 100644 --- a/components/console/test_apps/console/main/test_console.c +++ b/components/console/test_apps/console/main/test_console.c @@ -25,8 +25,8 @@ */ typedef struct { - const char *in; - const char *out; + const char *in; + const char *out; } cmd_context_t; static esp_console_repl_t *s_repl = NULL; @@ -239,8 +239,8 @@ TEST_CASE("esp console test with context", "[console]") }; cmd_context_t context1 = { - .in = "c2", - .out = NULL, + .in = "c2", + .out = NULL, }; const esp_console_cmd_t cmd0 = { @@ -252,11 +252,11 @@ TEST_CASE("esp console test with context", "[console]") }; const esp_console_cmd_t cmd1 = { - .command = "hello-c2", - .help = "Print Hello World in context c2", - .hint = NULL, - .func_w_context = do_hello_cmd_with_context, - .context = &context1, + .command = "hello-c2", + .help = "Print Hello World in context c2", + .hint = NULL, + .func_w_context = do_hello_cmd_with_context, + .context = &context1, }; TEST_ESP_OK(esp_console_cmd_register(&cmd0)); diff --git a/tools/ci/astyle-rules.yml b/tools/ci/astyle-rules.yml index 825c18801a..e7b761b8b9 100644 --- a/tools/ci/astyle-rules.yml +++ b/tools/ci/astyle-rules.yml @@ -49,7 +49,6 @@ components_not_formatted_temporary: - "/components/bootloader/" - "/components/bt/" - "/components/cmock/" - - "/components/console/" - "/components/efuse/" - "/components/esp_coex/" - "/components/esp_eth/"