cederom commented on PR #4110:
URL: https://github.com/apache/nuttx-apps/pull/4110#issuecomment-7084664110
Thank you @JianyuWang0623 remarks below :-)
**Verdict: request changes.** It won't compile when `CONFIG_PM=y` and
`CONFIG_BOARDCTL=n`. The rest are small fixes.
### Must fix
1. **Wrong config guard.** In `include/sys/boardctl.h`, everything sits
inside `#ifdef CONFIG_BOARDCTL` (lines 52–374 and 412–477):
`BOARDIOC_PM_CONTROL`, `struct boardioc_pm_ctrl_s`, the `BOARDIOC_PM_*` enum
and the `boardctl()` prototype itself. The `boardctl` syscall only exists with
`CONFIG_BOARDCTL`, and `CONFIG_PM` doesn't select it. So with PM on and
BOARDCTL off, `cmd_pmconfig()` fails with an incomplete struct and undeclared
identifiers. The other boardctl-based builtins in nxinit are gated on
`CONFIG_BOARDCTL_*` options, which depend on BOARDCTL. Use `#if
defined(CONFIG_BOARDCTL) && defined(CONFIG_PM)` in all four places in
`builtin.c` and in the test. NSH's own `cmd_pmconfig` has the same gap already,
but that's no reason to copy it.
2. **The test calls a kernel function directly.** `pm_staycount()` is not a
syscall, so `nxinit_unit_test` won't link in protected or kernel builds. Read
the count through `boardctl(BOARDIOC_PM_CONTROL)` with `action =
BOARDIOC_PM_STAYCOUNT` and use `ctrl.count`. That works in every build mode and
goes through the same path the command uses.
### Should fix
3. **Bad domain strings are accepted.** `atoi("foo")` and `atoi("1x")` both
quietly give a valid domain, so a typo in init.rc ends up holding domain 0.
Parse with `strtol()` and reject the value if `*end != '\0'`. Add a non-numeric
domain case to the test. Rejecting negative domains is already better than NSH,
which only checks the upper bound.
4. **The domain test doesn't prove much.** `staydom`/`relaxdom` pass `"0"`,
which is also the default, so the test would pass even if argv[3] were ignored.
When `CONFIG_PM_NDOMAINS > 1`, also test domain 1 and check that domain 0's
count doesn't change.
5. **Small behaviour change for init.rc files on NSH systems.** Before this,
a bare `pmconfig` or `pmconfig <domain>` line (NSH's query form, 1–2 args) went
to NSH. Now nxinit matches the name, the args fail the 3–4 check, and the line
returns `-EINVAL` without falling back to NSH. A query in init.rc is probably
rare, but the commit message or docs should mention it.
Btw we use `Assisted-by:` tag for AI agents credits, please update
`Co-authored-by:` with `Assisted-by:`, see
https://nuttx.apache.org/docs/latest/contributing/guide.html#commit-requirements
:-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]