You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/10/13 01:28:58 UTC

(nuttx-apps) branch master updated (53ff941e3 -> fb8bb0562)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


    from 53ff941e3 examples/pmstress: Add a power management current staircase.
     new ed6e03e23 system/nxinit: skip actions without commands
     new fb8bb0562 system/nxinit: test that an empty action is skipped

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 system/nxinit/action.c                  |  7 +++++++
 system/nxinit/test/test_nxinit.c        |  1 +
 system/nxinit/test/test_nxinit.h        |  1 +
 system/nxinit/test/test_nxinit_action.c | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+)


(nuttx-apps) 01/02: system/nxinit: skip actions without commands

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit ed6e03e2320531c3ea2216a04050452fff3802f3
Author: Kai Cheng <ch...@xiaomi.com>
AuthorDate: Sun Oct 11 19:27:30 2026 +0800

    system/nxinit: skip actions without commands
    
    An "on" section can end up with an empty command list: the section line
    is accepted on its own, and a board whose init.rc goes through the C
    preprocessor can have every command inside the section compiled out.
    add_ready() queued such an action anyway, and init_action_run_command()
    then took the head of its empty command list, which
    list_peek_head_type() reports as NULL, and dereferenced it.
    
    Do not queue an action that has no commands.
    
    Assisted-by: Kiro:claude-opus-5
    Signed-off-by: Kai Cheng <ch...@xiaomi.com>
    Signed-off-by: wangjianyu3 <wa...@xiaomi.com>
---
 system/nxinit/action.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/system/nxinit/action.c b/system/nxinit/action.c
index 6b2d166b7..d83790a27 100644
--- a/system/nxinit/action.c
+++ b/system/nxinit/action.c
@@ -112,6 +112,13 @@ static void add_ready(FAR struct action_manager_s *am,
     }
 #endif
 
+  /* An "on" section can end up without any command */
+
+  if (list_is_empty(&a->cmds))
+    {
+      return;
+    }
+
   list_for_every_entry(&am->ready_actions, ready, struct action_s,
                        ready_node)
     {


(nuttx-apps) 02/02: system/nxinit: test that an empty action is skipped

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit fb8bb05629f69804b4f6711074a3a9397d375cf0
Author: wangjianyu3 <wa...@xiaomi.com>
AuthorDate: Sun Oct 11 19:27:30 2026 +0800

    system/nxinit: test that an empty action is skipped
    
    Parse an "on" section with no command under it, trigger its event, and
    check that it never reaches the ready queue and that
    init_action_run_command() reports INT_MAX instead of taking the head of
    an empty command list.
    
    Without the preceding fix this test fails at the ready-queue assertion,
    and removing that assertion so the run path is reached crashes on a NULL
    dereference.
    
    Assisted-by: Kiro:claude-opus-5
    Signed-off-by: wangjianyu3 <wa...@xiaomi.com>
---
 system/nxinit/test/test_nxinit.c        |  1 +
 system/nxinit/test/test_nxinit.h        |  1 +
 system/nxinit/test/test_nxinit_action.c | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/system/nxinit/test/test_nxinit.c b/system/nxinit/test/test_nxinit.c
index 21fc7d309..cc76ef504 100644
--- a/system/nxinit/test/test_nxinit.c
+++ b/system/nxinit/test/test_nxinit.c
@@ -55,6 +55,7 @@ int main(int argc, FAR char *argv[])
       cmocka_unit_test(test_nxinit_action_event_match_invert),
       cmocka_unit_test(test_nxinit_action_event_match_fnmatch),
       cmocka_unit_test(test_nxinit_action_event_and_semantics),
+      cmocka_unit_test(test_nxinit_action_empty_skipped),
       cmocka_unit_test(test_nxinit_service_duplicate_conflict),
       cmocka_unit_test(test_nxinit_service_override_replaces_duplicate),
       cmocka_unit_test(test_nxinit_service_args_max_boundary),
diff --git a/system/nxinit/test/test_nxinit.h b/system/nxinit/test/test_nxinit.h
index 06c086dd5..2d53e5ae6 100644
--- a/system/nxinit/test/test_nxinit.h
+++ b/system/nxinit/test/test_nxinit.h
@@ -69,6 +69,7 @@ void test_nxinit_action_event_match_exact(FAR void **state);
 void test_nxinit_action_event_match_invert(FAR void **state);
 void test_nxinit_action_event_match_fnmatch(FAR void **state);
 void test_nxinit_action_event_and_semantics(FAR void **state);
+void test_nxinit_action_empty_skipped(FAR void **state);
 
 /****************************************************************************
  * Name: test_nxinit_service_*
diff --git a/system/nxinit/test/test_nxinit_action.c b/system/nxinit/test/test_nxinit_action.c
index 0bdfce10d..7fe229ddb 100644
--- a/system/nxinit/test/test_nxinit_action.c
+++ b/system/nxinit/test/test_nxinit_action.c
@@ -28,6 +28,7 @@
 #include <nuttx/list.h>
 
 #include <setjmp.h>
+#include <limits.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -260,3 +261,34 @@ void test_nxinit_action_event_and_semantics(FAR void **state)
   skip();
 #endif
 }
+
+/****************************************************************************
+ * Name: test_nxinit_action_empty_skipped
+ *
+ * Description:
+ *   An "on" section that holds no command must never reach the ready
+ *   queue. init_action_run_command() takes the head of the ready
+ *   action's command list, which list_peek_head_type() reports as NULL
+ *   for an empty list, and then dereferences it.
+ ****************************************************************************/
+
+void test_nxinit_action_empty_skipped(FAR void **state)
+{
+  struct action_manager_s am;
+  struct parser_s parser =
+    {
+      "on", init_action_parse, NULL, &am
+    };
+
+  char section[] = "on property:sys.boot.reason=bootloader";
+
+  action_manager_init(&am);
+
+  assert_int_equal(init_action_parse(&parser, true, section), 0);
+
+  init_action_trigger_event(&am, "sys.boot.reason", "bootloader");
+  assert_false(action_manager_has_ready(&am));
+  assert_int_equal(init_action_run_command(&am), INT_MAX);
+
+  action_manager_free_all(&am);
+}