From 4d5c5b363ec5935718fd93fbc822d75c4454818b Mon Sep 17 00:00:00 2001 From: Matteo Golin Date: Wed, 27 May 2026 19:42:10 -0400 Subject: [PATCH 1/4] apps/nxinit: Fix Kconfig typo Fix typo in help string. Signed-off-by: Matteo Golin --- system/nxinit/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/nxinit/Kconfig b/system/nxinit/Kconfig index 58d3c406ed2..fc2670312f8 100644 --- a/system/nxinit/Kconfig +++ b/system/nxinit/Kconfig @@ -77,7 +77,7 @@ config SYSTEM_NXINIT_ACTION_MANAGER_EVENT_MAX config SYSTEM_NXINIT_FINALINIT bool "Enable NXInit final event" default n - --help-- + ---help--- Enable support to run the "final" event. Currently only "boot", and "init" event are enabled by default, where "netinit" and "final" are optional. From 6c08b45f3d1e78e839a1981d65d5f63a7ebf87e6 Mon Sep 17 00:00:00 2001 From: Matteo Golin Date: Wed, 27 May 2026 19:52:02 -0400 Subject: [PATCH 2/4] apps/nxinit: Fix service length error Would not compile due to typo in macro describing service name length. Change ensures that: * We do not malloc an extra `len` bytes since this is already allocated as part of the struct * The name string always has a null terminating byte Signed-off-by: Matteo Golin FIx --- system/nxinit/service.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/nxinit/service.c b/system/nxinit/service.c index 847b1a31d35..7f582e6e4fb 100644 --- a/system/nxinit/service.c +++ b/system/nxinit/service.c @@ -206,9 +206,12 @@ static int option_class(FAR struct service_manager_s *sm, { FAR struct service_s *s = list_last_entry(&sm->services, struct service_s, node); - size_t len = strlen(argv[1]) + 1; + size_t len; FAR struct service_class_s *c; + len = strlen(argv[1]) + 1; + len = (len >= NXINIT_SERVICE_NAME_MAX) ? NXINIT_SERVICE_NAME_MAX : len; + list_for_every_entry(&s->classes, c, struct service_class_s, node) { if (!strcmp(c->name, argv[1])) @@ -217,15 +220,15 @@ static int option_class(FAR struct service_manager_s *sm, } } - c = malloc(sizeof(*c) + len); + c = malloc(sizeof(*c)); if (c == NULL) { init_err("Alloc class"); return -errno; } - len = (len >= MAX_NXINIT_SERVICE_NAME) ? MAX_NXINIT_SERVICE_NAME : len; memcpy(c->name, argv[1], len); + c->name[len] = '\0'; /* Always ensure null termination */ list_add_tail(&s->classes, &c->node); return 0; } From 28b3b2abd8420fcbd91d9fe87e7ed41040894ff1 Mon Sep 17 00:00:00 2001 From: Matteo Golin Date: Wed, 27 May 2026 19:32:57 -0400 Subject: [PATCH 3/4] apps/nxinit: Make init.rc file path configurable The init.rc file path is now configurable to allow users to choose where to put the startup script. This is useful for devices that mount external media to a special directory like `/sd`. Signed-off-by: Matteo Golin --- system/nxinit/Kconfig | 6 ++++++ system/nxinit/init.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/system/nxinit/Kconfig b/system/nxinit/Kconfig index fc2670312f8..e159e90b746 100644 --- a/system/nxinit/Kconfig +++ b/system/nxinit/Kconfig @@ -31,6 +31,12 @@ config SYSTEM_NXINIT_PROGNAME comment "NXInit Run Control(RC)" +config SYSTEM_NXINIT_RC_FILE_PATH + string "Path to RC file" + default "/etc/init.d/init.rc" + ---help--- + Path to the init.rc file to use for NXInit's boot logic. + config SYSTEM_NXINIT_RC_LINE_MAX int "Max line length of RC file" default 128 diff --git a/system/nxinit/init.c b/system/nxinit/init.c index 8a88c63d98d..d501abcad04 100644 --- a/system/nxinit/init.c +++ b/system/nxinit/init.c @@ -180,7 +180,7 @@ int main(int argc, FAR char *argv[]) } } - r = init_parse_config_file(parser, "/etc/init.d/init.rc"); + r = init_parse_config_file(parser, CONFIG_SYSTEM_NXINIT_RC_FILE_PATH); if (r < 0) { goto out; From cf5b8252f2780ef541a83b0f01cd6959cf7a9650 Mon Sep 17 00:00:00 2001 From: Matteo Golin Date: Wed, 27 May 2026 19:56:44 -0400 Subject: [PATCH 4/4] apps/nxinit: Fix uninitialized variable Without debug enabled, the code would not compile due to checking `WIFEXITED(wstatus)` when `wstatus` was uninitialized. Signed-off-by: Matteo Golin --- system/nxinit/init.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/system/nxinit/init.c b/system/nxinit/init.c index d501abcad04..1a542f79612 100644 --- a/system/nxinit/init.c +++ b/system/nxinit/init.c @@ -80,13 +80,7 @@ static void reap_process(FAR struct service_manager_s *sm, for (; ; ) { - pid = waitpid(-1, -#ifdef CONFIG_SYSTEM_NXINIT_DEBUG - &wstatus, -#else - NULL, -#endif - WNOHANG); + pid = waitpid(-1, &wstatus, WNOHANG); if (pid <= 0) { break;