sched/semaphore: Fix HIS_CALLS metric violation for MISRA compliance #18193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses Coverity's HIS_metric_violation(HIS_CALLS) warning in the semaphore implementation by reducing function call depth to comply with MISRA HIS (Harman Integration Safety Specification) coding standards. The refactoring maintains functional correctness while improving code maintainability and meeting safety-critical software requirements.
Key Improvements:
Background
HIS_CALLS Metric: MISRA HIS standard limits nested function call depth to reduce complexity and improve verifiability in safety-critical systems. The original implementation in sched/semaphore/sem_reset.c exceeded this threshold.
Coverity Analysis: Coverity static analysis tool identified this violation as a quality metric issue that should be resolved for compliance with embedded systems coding standards.
Impact
Safety & Compliance: Improves code quality metrics for safety-critical applications and embedded systems deployments.
Stability: No functional changes - all existing APIs and behavior preserved. All semaphore operations remain atomic and thread-safe.
Compatibility: 100% backward compatible. No API changes or behavioral modifications.
Performance: No performance impact. Code maintains same efficiency with simplified call structure.
Affected Areas:
sched/semaphore/sem_reset.cnxsem_reset(),reset_mutex(),reset_sem()2. Implementation Changes
reset_mutex()logic into main function path for common casereset_sem()with reduced helper function callsTesting
Test Environment
Test Scenarios