This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5ac016ad027c7bdfb3741097217f66520a5f0257 Author: yukangzhi <[email protected]> AuthorDate: Wed Oct 15 15:53:33 2025 +0800 sched/init: remove dead code in the PID hash sizing loop. In nx_start(), the PID hash starts at the power of two that is not less than CONFIG_PID_INITIAL_COUNT and is doubled while it cannot hold more than CONFIG_SMP_NCPUS entries. When CONFIG_SMP_NCPUS is smaller than CONFIG_PID_INITIAL_COUNT the loop body can never run, and Coverity reports "i <<= 1" as dead code. Only compile the loop when CONFIG_SMP_NCPUS >= CONFIG_PID_INITIAL_COUNT. Assisted-by: Kiro Signed-off-by: yukangzhi <[email protected]> --- sched/init/nx_start.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 6c4cd3e078f..3abae8bf711 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -568,10 +568,12 @@ void nx_start(void) /* Initialize the logic that determine unique process IDs. */ i = 1 << LOG2_CEIL(CONFIG_PID_INITIAL_COUNT); +#if CONFIG_SMP_NCPUS >= CONFIG_PID_INITIAL_COUNT while (i <= CONFIG_SMP_NCPUS) { i <<= 1; } +#endif g_pidhash = kmm_zalloc(sizeof(*g_pidhash) * i); DEBUGASSERT(g_pidhash);
