Skip to content

Conversation

@behlendorf
Copy link
Contributor

Motivation and Context

As discussed in #17885 we want to enforce certain cstyle guidelines and catch bugs early in the development process. Adding the smatch code checker to the CI can help with both of these things. This PR automates running the analysis but it will take a concerted effort to resolve all the warnings.

Description

Smatch is an actively maintained kernel-aware static analyzer for C with a low false positive rate. Since the code checker can be run relatively quickly against the entire OpenZFS code base (15 min) it makes sense to add it as a GitHub Actions workflow. Today smatch reports a significant numbers warnings so the workflow is configured to always pass as long as the analysis was run. The results are available for reference. Long term it would ideal to resolve all of the errors/warnings at which point the workflow can be updated to fail when new problems are detected.

How Has This Been Tested?

Lightly tested here, https://github.com/behlendorf/zfs/actions/runs/19380431337

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Nov 14, 2025
@behlendorf behlendorf mentioned this pull request Nov 14, 2025
10 tasks
@behlendorf behlendorf force-pushed the smatch-workflow branch 2 times, most recently from 4c15108 to 8eb1ad7 Compare November 15, 2025 02:17
Smatch is an actively maintained kernel-aware static analyzer
for C with a low false positive rate.  Since the code checker
can be run relatively quickly against the entire OpenZFS code
base (15 min) it makes sense to add it as a GitHub Actions
workflow.  Today smatch reports a significant numbers warnings
so the workflow is configured to always pass as long as the
analysis was run.  The results are available for reference.
Long term it would ideal to resolve all of the errors/warnings
at which point the workflow can be updated to fail when new
problems are detected.

ZFS-CI-Type: quick
Signed-off-by: Brian Behlendorf <[email protected]>
@tsoome
Copy link
Contributor

tsoome commented Nov 15, 2025

Do you have sample output from smatch too?

@AttilaFueloep
Copy link
Contributor

I'd a look at the ICP smatch errors. They're all about uninitialized symbols and caused by the fact that smatch doesn't know about __builtin_unreachable. Haven't done research on how to teach smatch that __builtin_unreachable denotes unreachable code yet. Maybe someone else knows how to handle this.

@tsoome I picked them up below the second Make entry here.

@tsoome
Copy link
Contributor

tsoome commented Nov 17, 2025

I'd a look at the ICP smatch errors. They're all about uninitialized symbols and caused by the fact that smatch doesn't know about __builtin_unreachable. Haven't done research on how to teach smatch that __builtin_unreachable denotes unreachable code yet. Maybe someone else knows how to handle this.

@tsoome I picked them up below the second Make entry here.

I see. I think, this is good point to check with Dan Carpenter :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Code Review Needed Ready for review and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants