Skip to content

system/nxinit: drop unreachable error checks - #3938

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
JianyuWang0623:nxinit-drop-unreachable-error-checks
Oct 30, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
JianyuWang0623:nxinit-drop-unreachable-error-checks

Conversation

@JianyuWang0623

Copy link
Copy Markdown
Contributor

Summary

Coverity reports the t1 < 0 / t2 < 0 checks in the nxinit main loop as
dead code: init_service_refresh() and init_action_run_command() only return
non-negative wait times, and errors are handled by the ppoll() branch below.
Remove the two unreachable checks; behavior is unchanged.

Impact

No behavior change: the removed branches were unreachable. No impact on
build, configuration, documentation, security, or compatibility.

Testing

  • Host: Ubuntu 22.04.5 LTS, x86_64, gcc 13.4.0
  • Target: sim:nsh (apache/nuttx master + this patch; the defconfig
    enables CONFIG_SYSTEM_NXINIT=y)
  • Build: full build passes; all nxinit sources are compiled and linked.
  • Runtime: sim boots to nsh; uname -a, free and poweroff work as
    expected and the process exits with 0.

init_service_refresh() and init_action_run_command() only return
non-negative wait times and report errors through the ppoll() branch
below, so the t1/t2 < 0 checks in the main loop are dead code (Coverity).

Assisted-by: OpenCode:mimo-v2.6-pro
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623
JianyuWang0623 marked this pull request as ready for review October 29, 2026 13:35

@cederom cederom left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @JianyuWang0623 :-)

Can there be a problem when time changes (i.e. due to ntp update)? Was that the main intention? Maybe t2 > t1 check is enough and still necessary?

@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

Thank you @JianyuWang0623 :-)

Can there be a problem when time changes (i.e. due to ntp update)? Was that the main intention? Maybe t2 > t1 check is enough and still necessary?

@cederom Thanks for the question. All timestamps are from CLOCK_MONOTONIC, so NTP time jumps cannot result in negative t1/t2.

@xiaoxiang781216
xiaoxiang781216 merged commit 7879139 into apache:master Oct 30, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants