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 8984981318e2b6052fecb1cee35351870333b885 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Sat May 31 19:01:47 2025 +0200 sys/stats: Register commands statically Now stat cli commands are register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <[email protected]> --- sys/stats/full/include/stats/stats.h | 3 --- sys/stats/full/pkg.yml | 7 +++++++ sys/stats/full/src/stats.c | 7 ------- sys/stats/full/src/stats_shell.c | 23 +++-------------------- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/sys/stats/full/include/stats/stats.h b/sys/stats/full/include/stats/stats.h index 82621fa0d..ef86e9b7c 100644 --- a/sys/stats/full/include/stats/stats.h +++ b/sys/stats/full/include/stats/stats.h @@ -217,9 +217,6 @@ struct stats_hdr *stats_group_find(const char *name); #if MYNEWT_VAL(STATS_MGMT) int stats_mgmt_register_group(void); #endif -#if MYNEWT_VAL(STATS_CLI) -int stats_shell_register(void); -#endif #if MYNEWT_VAL(STATS_PERSIST) diff --git a/sys/stats/full/pkg.yml b/sys/stats/full/pkg.yml index 683324674..fc320c7bb 100644 --- a/sys/stats/full/pkg.yml +++ b/sys/stats/full/pkg.yml @@ -33,9 +33,16 @@ pkg.deps.STATS_CLI: pkg.deps.STATS_MGMT: - "@apache-mynewt-mcumgr/cmd/stat_mgmt" +pkg.whole_archive: true + pkg.init: stats_module_init: 'MYNEWT_VAL(STATS_SYSINIT_STAGE)' +pkg.source_files: + - src/stats.c +pkg.source_files.STATS_CLI: + - src/stats_shell.c + pkg.init.STATS_PERSIST: stats_conf_init: 'MYNEWT_VAL(STATS_SYSINIT_STAGE_CONF)' diff --git a/sys/stats/full/src/stats.c b/sys/stats/full/src/stats.c index 0a6494492..fc8410b7b 100644 --- a/sys/stats/full/src/stats.c +++ b/sys/stats/full/src/stats.c @@ -157,13 +157,6 @@ stats_module_init_internal(void) return rc; } -#if MYNEWT_VAL(STATS_CLI) - rc = stats_shell_register(); - if (rc) { - return rc; - } -#endif - return rc; } diff --git a/sys/stats/full/src/stats_shell.c b/sys/stats/full/src/stats_shell.c index b9cf8c5b7..5fd7b5b56 100644 --- a/sys/stats/full/src/stats_shell.c +++ b/sys/stats/full/src/stats_shell.c @@ -33,14 +33,8 @@ static int shell_stats_display(const struct shell_cmd *cmd, int argc, char **argv, struct streamer *streamer); -static struct shell_cmd shell_stats_cmd = - SHELL_CMD_EXT("stat", shell_stats_display, NULL); - -uint8_t stats_shell_registered; - -static int -stats_shell_display_entry(struct stats_hdr *hdr, void *arg, char *name, - uint16_t stat_off) +static int +stats_shell_display_entry(struct stats_hdr *hdr, void *arg, char *name, uint16_t stat_off) { struct streamer *streamer; void *stat_val; @@ -114,17 +108,6 @@ err: return (rc); } - -int -stats_shell_register(void) -{ - if (!stats_shell_registered) { - stats_shell_registered = 1; - shell_cmd_register(&shell_stats_cmd); - } - - return (0); -} - +MAKE_SHELL_EXT_CMD(stat, shell_stats_display, NULL) #endif
