You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2025/11/07 16:53:05 UTC
(mynewt-core) 05/26: sys/log: Register commands statically
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 36ca652d93479d11e4b445d2311bf2fc145c0b04
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Sat May 31 22:58:03 2025 +0200
sys/log: Register commands statically
Now log shell commands are register at link time to
reduce memory footprint.
No change in functionality.
Remove unfinished code depending on non-existing
flag LOG_FCB_SLOT1.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
sys/log/full/pkg.yml | 3 +--
sys/log/full/src/log.c | 33 ---------------------------------
sys/log/full/src/log_shell.c | 18 +++++++++---------
3 files changed, 10 insertions(+), 44 deletions(-)
diff --git a/sys/log/full/pkg.yml b/sys/log/full/pkg.yml
index 363a3dc1c..4e438c987 100644
--- a/sys/log/full/pkg.yml
+++ b/sys/log/full/pkg.yml
@@ -67,5 +67,4 @@ pkg.req_apis.LOG_STATS:
pkg.init:
log_init: 'MYNEWT_VAL(LOG_SYSINIT_STAGE_MAIN)'
-pkg.init.LOG_CLI_FILL_CMD:
- shell_log_fill_register: $after:shell_init
+pkg.whole_archive: true
diff --git a/sys/log/full/src/log.c b/sys/log/full/src/log.c
index dcdff66b4..10af4fe86 100644
--- a/sys/log/full/src/log.c
+++ b/sys/log/full/src/log.c
@@ -50,30 +50,6 @@ static struct log_module_entry g_log_module_list[
static int g_log_module_count;
static uint8_t log_written;
-#if MYNEWT_VAL(LOG_CLI)
-int shell_log_dump_cmd(int, char **);
-struct shell_cmd g_shell_log_cmd = {
- .sc_cmd = "log",
- .sc_cmd_func = shell_log_dump_cmd
-};
-
-#if MYNEWT_VAL(LOG_FCB_SLOT1)
-int shell_log_slot1_cmd(int, char **);
-struct shell_cmd g_shell_slot1_cmd = {
- .sc_cmd = "slot1",
- .sc_cmd_func = shell_log_slot1_cmd,
-};
-#endif
-
-#if MYNEWT_VAL(LOG_STORAGE_INFO)
-int shell_log_storage_cmd(int, char **);
-struct shell_cmd g_shell_storage_cmd = {
- .sc_cmd = "log-storage",
- .sc_cmd_func = shell_log_storage_cmd,
-};
-#endif
-#endif
-
#if MYNEWT_VAL(LOG_STATS)
STATS_NAME_START(logs)
STATS_NAME(logs, writes)
@@ -149,15 +125,6 @@ log_init(void)
#if MYNEWT_VAL(LOG_GLOBAL_IDX)
g_log_info.li_next_index = 0;
#endif
-#if MYNEWT_VAL(LOG_CLI)
- shell_cmd_register(&g_shell_log_cmd);
-#if MYNEWT_VAL(LOG_FCB_SLOT1)
- shell_cmd_register(&g_shell_slot1_cmd);
-#endif
-#if MYNEWT_VAL(LOG_STORAGE_INFO)
- shell_cmd_register(&g_shell_storage_cmd);
-#endif
-#endif
#if MYNEWT_VAL(LOG_CONSOLE)
log_console_init();
diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c
index 8229432a9..d17043e55 100644
--- a/sys/log/full/src/log_shell.c
+++ b/sys/log/full/src/log_shell.c
@@ -392,6 +392,7 @@ err:
return (rc);
}
+MAKE_SHELL_CMD(log, shell_log_dump_cmd, NULL)
#if MYNEWT_VAL(LOG_STORAGE_INFO)
int
@@ -425,8 +426,13 @@ shell_log_storage_cmd(int argc, char **argv)
return (0);
}
+
+SHELL_MODULE_CMD_WITH_NAME(compat, log_storage, "log-storage", 0,
+ shell_log_storage_cmd, NULL)
+
#endif
+#if MYNEWT_VAL(LOG_CLI_FILL_CMD)
static int
log_fill_command(int argc, char **argv)
{
@@ -458,14 +464,8 @@ log_fill_command(int argc, char **argv)
return 0;
}
-static struct shell_cmd log_fill_cmd = {
- .sc_cmd = "log-fill",
- .sc_cmd_func = log_fill_command
-};
+SHELL_MODULE_CMD_WITH_NAME(compat, log_fill, "log-fill", 0, log_fill_command, NULL)
+
+#endif
-void
-shell_log_fill_register(void)
-{
- shell_cmd_register(&log_fill_cmd);
-}
#endif