RTEMS | cpukit/librtemscxx: Initialize spolicy in start_thread (CID 1592923) (!1053)

MITHILESH MATTAPALLI (@mithileshm) gitlab at rtems.org
Sat Feb 7 18:33:09 UTC 2026



MITHILESH MATTAPALLI created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1053

Project:Branches: mithileshm/rtems:fix-cxx-thread-uninit to rtems/rtos/rtems:main
Author:   MITHILESH MATTAPALLI



**Summary**

Initialize the scalar variable spolicy in thread::start_thread to prevent potential use of an uninitialized variable.

Analysis: Static analysis (Coverity) flagged the spolicy variable in cpukit/librtemscxx/thread.cpp as an uninitialized scalar. While the subsequent switch statement logic covers the known cases, there is a theoretical path where the variable could remain uninitialized before being passed to pthread_attr_setschedpolicy.

This patch initializes spolicy to SCHED_FIFO at the point of declaration. SCHED_FIFO was selected because it matches the existing default case fallback in the switch statement, ensuring the fix is consistent with the original design intent.

Testing:

* Built cpukit successfully with the change.
* Verified that the initialization value matches the logic in the existing default switch case.

Generative AI: None used

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1053
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260207/7db57c17/attachment-0001.htm>


More information about the bugs mailing list