Skip to content

Comments

cpuset: fix cppcheck missingReturn errors#26

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-cppcheck-findings
Draft

cpuset: fix cppcheck missingReturn errors#26
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-cppcheck-findings

Conversation

Copy link

Copilot AI commented Feb 22, 2026

Functions in src/cpuset.c using #if/#elif preprocessor chains without a final #else clause trigger cppcheck missingReturn errors, since no return statement exists when none of the defined macros match.

Changes

  • Added #else return 0; fallback to the six affected functions:
    • ha_cpuset_set, ha_cpuset_clr — already had an early return 1 guard, missing #else in the macro chain
    • ha_cpuset_count, ha_cpuset_ffs, ha_cpuset_isequal, ha_cpuset_size — no fallback path at all

Before:

int ha_cpuset_size()
{
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
    return CPU_SETSIZE;
#elif defined(CPUSET_USE_ULONG)
    return LONGBITS;
#endif  // ← no return if neither macro is defined
}

After:

int ha_cpuset_size()
{
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
    return CPU_SETSIZE;
#elif defined(CPUSET_USE_ULONG)
    return LONGBITS;
#else
    return 0;
#endif
}
Original prompt

This section details on the original issue you should resolve

<issue_title>fix cppcheck finding</issue_title>
<issue_description>we need to address the following cppcheck finding

src/cpuset.c:21:11: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:36:11: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:100:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:124:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:152:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:163:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cppcheck findings in cpuset.c cpuset: fix cppcheck missingReturn errors Feb 22, 2026
Copilot AI requested a review from chipitsine February 22, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix cppcheck finding

2 participants