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 337c31b3d3027cac645ca464c769ff39b0c7d2fb
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Sun Jun 1 10:41:46 2025 +0200

    mgmt/imgmgr: Register commands statically
    
    Now imgr shell command is register at link time to
    reduce memory footprint.
    No change in functionality.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 mgmt/imgmgr/pkg.yml           |  2 ++
 mgmt/imgmgr/src/imgmgr.c      |  8 --------
 mgmt/imgmgr/src/imgmgr_cli.c  | 12 ++----------
 mgmt/imgmgr/src/imgmgr_priv.h |  1 -
 4 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/mgmt/imgmgr/pkg.yml b/mgmt/imgmgr/pkg.yml
index 08bdde84d..6dabb27ea 100644
--- a/mgmt/imgmgr/pkg.yml
+++ b/mgmt/imgmgr/pkg.yml
@@ -45,5 +45,7 @@ pkg.deps.IMGMGR_CLI:
     - "@apache-mynewt-core/sys/shell"
     - "@apache-mynewt-core/util/parse"
 
+pkg.whole_archive: true
+
 pkg.init:
     imgmgr_module_init: 'MYNEWT_VAL(IMGMGR_SYSINIT_STAGE)'
diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index d240937ce..69d8f838c 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -276,16 +276,8 @@ imgr_erase_state(struct mgmt_ctxt *ctxt)
 void
 imgmgr_module_init(void)
 {
-    int rc;
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
 
     mgmt_register_group(&imgr_mgmt_group);
-
-#if MYNEWT_VAL(IMGMGR_CLI)
-    rc = imgr_cli_register();
-    SYSINIT_PANIC_ASSERT(rc == 0);
-#else
-    (void) rc;
-#endif
 }
diff --git a/mgmt/imgmgr/src/imgmgr_cli.c b/mgmt/imgmgr/src/imgmgr_cli.c
index 2dc39d0a6..2d8b1e34f 100644
--- a/mgmt/imgmgr/src/imgmgr_cli.c
+++ b/mgmt/imgmgr/src/imgmgr_cli.c
@@ -52,11 +52,6 @@ static const struct shell_cmd_help imgr_cli_help = {
 };
 #endif
 
-static struct shell_cmd shell_imgr_cmd[] = {
-    SHELL_CMD_EXT("imgr", imgr_cli_cmd, &imgr_cli_help),
-    { 0 },
-};
-
 static void
 imgr_cli_too_few_args(struct streamer *streamer)
 {
@@ -261,9 +256,6 @@ imgr_cli_cmd(const struct shell_cmd *cmd, int argc, char 
**argv, struct streamer
     return 0;
 }
 
-int
-imgr_cli_register(void)
-{
-    return shell_cmd_register(shell_imgr_cmd);
-}
+MAKE_SHELL_EXT_CMD(imgr, imgr_cli_cmd, &imgr_cli_help)
+
 #endif /* MYNEWT_VAL(IMGMGR_CLI) */
diff --git a/mgmt/imgmgr/src/imgmgr_priv.h b/mgmt/imgmgr/src/imgmgr_priv.h
index 9f52610d5..e57910be1 100644
--- a/mgmt/imgmgr/src/imgmgr_priv.h
+++ b/mgmt/imgmgr/src/imgmgr_priv.h
@@ -87,7 +87,6 @@ int imgr_core_load(struct mgmt_ctxt *);
 int imgr_core_erase(struct mgmt_ctxt *);
 int imgr_find_by_ver(struct image_version *find, uint8_t *hash);
 int imgr_find_by_hash(uint8_t *find, struct image_version *ver);
-int imgr_cli_register(void);
 
 #ifdef __cplusplus
 }

Reply via email to