hujun260 opened a new pull request, #18212:
URL: https://github.com/apache/nuttx/pull/18212

   ## Summary
   Consolidate multiple return statements in the 
`nxsched_get_fdlist_from_tcb()` 
   function into a single exit point to improve code quality and comply with 
MISRA 
   HIS coding standards for safety-critical systems.
   
   ## Motivation and Problem
   The original implementation had multiple return points (early return for 
success 
   and return at the end for failure), which violates MISRA HIS metric rules 
for 
   safety-critical code. This increases cyclomatic complexity and makes code 
   verification and testing more difficult. Consolidating returns to a single 
exit 
   point improves maintainability and compliance with automotive safety 
standards.
   
   ## Changes
   - Introduce a result variable (`ret`) initialized to NULL
   - Replace early success return with assignment to `ret`
   - Perform single return at function end with the result variable
   
   ## Impact
   - **Code Quality**: Reduced cyclomatic complexity
   - **Compliance**: Achieves MISRA HIS compliance for return statement metrics
   - **Verifiability**: Single exit point improves static analysis and code 
verification
   - **Backward Compatibility**: No functional changes; identical runtime 
behavior
   - **Performance**: No performance impact; compiler optimizations identical
   
   ## Verification
   - [x] Code compiles without warnings on ARM GCC 10.x
   - [x] Verified on QEMU ARMv7-A simulator with multimedia profile
   - [x] File descriptor list retrieval verified
   - [x] NULL return for invalid task group verified
   - [x] Valid file descriptor list pointer return verified
   - [x] Static analysis shows improved complexity metrics
   
   ## Testing
   Tested with:
   - ARM GCC 10.x compiler
   - QEMU ARMv7-A simulation
   - Task file descriptor list operations:
     - Valid task group with file descriptors
     - Invalid/NULL task group handling
     - File descriptor list pointer validity
   
   
   
   ## Files Changed
   - `sched/sched/sched_getfiles.c` (5 lines: 3 insertions, 2 deletions)


-- 
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]

Reply via email to