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 df01c3cbfc0adc42296583b01f58a180f50bddc2 Author: wangjianyu3 <[email protected]> AuthorDate: Thu Oct 16 16:58:21 2025 +0800 system/nxinit: Handle trailing file '\0' When ETC_ROMFS is disabled to reduce the bin size, we can provide the init.rc file via a pseudo-file in the boards/vendor directory. For example: - CONFIG_ETC_ROMFS=n - CONFIG_PSEUDOFS_FILE=y - CONFIG_DISABLE_PSEUDOFS_OPERATIONS=n ```C FAR const char *init_rc = "on init\n" " start console\n"; "service console sh\n" " restart_period 100\n"; int fd = open("/etc/init.d/init.rc", O_WRONLY | O_CREAT); /* ... */ ssize_t n = write(fd, init_rc, strlen(init_rc) + 1); /* ... */ close(fd); ``` The last character '\0' in the file content will be treated as a new line, and the number of parsed parameters will be zero (abnormal, there should be at least one keyword). Signed-off-by: wangjianyu3 <[email protected]> --- system/nxinit/parser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/nxinit/parser.c b/system/nxinit/parser.c index 0c91703f8..11c90c00d 100644 --- a/system/nxinit/parser.c +++ b/system/nxinit/parser.c @@ -178,6 +178,10 @@ int init_parse_config_file(FAR const struct parser_s *parser, *(nl++) = '\0'; n -= nl - buf; init_debug("Line %3d: '%s'", ++line, buf); + if (*buf == '\0') + { + continue; + } /* Skip empty lines and lines containing only whitespace */
