Repository navigation
system/nxinit: Check CONFIG_SYSTEM_NXINIT_UMASK at build time. - #4082
Merged
Merged
Conversation
init checked CONFIG_SYSTEM_NXINIT_UMASK at run time and reported a bad value only with init_err(). Without init error logs, init then kept the umask 0 with no message. The Make and CMake builds now give the value to init.c as the octal constant NXINIT_UMASK. An #if with #error stops the build when the value is less than 0 or more than 0777, and the compiler stops it when the value has a character that is not an octal digit. At run time, init only calls umask() with the constant. The default stays empty: init then does not call umask(). Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
CI run: https://github.com/apache/nuttx-apps/actions/runs/44282204917 |
casaroli
marked this pull request as draft
November 18, 2026 14:15
casaroli
marked this pull request as ready for review
November 18, 2026 14:15
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): CI run: https://github.com/apache/nuttx-apps/actions/runs/44322318200 |
xiaoxiang781216
approved these changes
Nov 19, 2026
JianyuWang0623
approved these changes
Nov 19, 2026
jerpelea
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#4077 added
CONFIG_SYSTEM_NXINIT_UMASK, an octal string. init checked the value at run time and reported a bad value only withinit_err(). A review of #4077 noted thatinit_err()compiles out without the init error log, so init then keeps the umask 0 with no message.This PR checks the value at build time. The Make and CMake builds give a non-empty value to init.c as the octal constant
NXINIT_UMASK(the build puts a0before the digits). In init.c,#ifwith#errorstops the build when the value is less than 0 or more than 0777. A character that is not an octal digit stops the build in the same#if, because the constant is not a valid octal number. At run time, init only callsumask(NXINIT_UMASK).The option stays a string, so that empty means "do not call
umask()", and the usual form022stays.Impact
No change for existing configurations: the default is empty, the build then gives no
NXINIT_UMASK, and init does not callumask(). A valid value works as before. A bad value now stops the build, before it gave an error message at run time (only with the init error log) and init kept the umask. The code is in the init program only, the same in flat, protected and kernel builds. The documentation (Documentation/applications/system/nxinit/index.rst) does not describe a bad value, so it needs no change.Testing
Build checks (the logs have the full messages). Make: qemu-armv8a:nsh (arm64, GCC 14.2.1) and sim:nsh (macOS host, Apple clang 21.0.0). CMake: qemu-armv8a:nsh (GCC 14.2.1, Ninja).
CONFIG_SYSTEM_NXINIT_UMASKNXINIT_UMASK022,0022,0,777,07771000,-1#error "CONFIG_SYSTEM_NXINIT_UMASK must be an octal number from 0 to 777"#error8error: invalid digit "8" in octal constanterror: invalid digit '8' in octal constantabcerror: invalid suffix "abc" on integer constanterror: invalid digit 'a' in octal constant0x12error: invalid suffix "x12" on integer constanterror: invalid suffix 'x12' on integer constant022(a space before)error: missing binary operator before token "022"error: token is not a valid binary operator in a preprocessor subexpressionEach compiler error points at the
#ifline in init.c (GCC: "in expansion of macro 'NXINIT_UMASK'", clang: "expanded from macro 'NXINIT_UMASK'"). The CMake build ran"",022,8,1000,022,0x12,-1,777,"",022in one build directory, with the same results and messages as Make. The define follows the value, and it goes away again for the empty value.Run: qemu-armv8a:nsh (flat build, arm64, QEMU), Make build, with
CONFIG_FS_PERMISSION(andSCHED_USER_IDENTITY,PSEUDOFS_ATTRIBUTES), so that tmpfs keeps the file modes. Commands in nsh:mkdir /tmp/d,echo x > /tmp/f,ls -l /tmp.CONFIG_SYSTEM_NXINIT_UMASK/tmp/d/tmp/fdrwxrwxrwx-rw-rw-rw-022drwxr-xr-x-rw-r--r--Size (text, the same configuration, master -> this PR): with
022, init.c 1084 -> 993 bytes and the image 371676 -> 371584 bytes. With the default, no change: init.c 985 bytes, the image 371516 bytes.The cmocka unit tests (
CONFIG_SYSTEM_NXINIT_TEST) with022: the Make build builds, andnxinit_unit_testpasses 22 of 22 tests in QEMU. The CMake build builds; there the define is only on the sources of init, not on those ofnxinit_unit_test.tools/checkpatch.sh passes.