Skip to content

CI: Add smatch static analysis workflow - #17935

Merged
behlendorf merged 1 commit into
openzfs:masterfrom
behlendorf:smatch-workflow
Nov 17, 2025
Merged

behlendorf merged 1 commit into
openzfs:masterfrom
behlendorf:smatch-workflow

Conversation

@behlendorf

Copy link
Copy Markdown
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 3 times, most recently from 8eb1ad7 to 9f00998 Compare November 15, 2025 16:25
@tsoome

tsoome commented Nov 15, 2025

Copy link
Copy Markdown
Contributor

Do you have sample output from smatch too?

@AttilaFueloep

Copy link
Copy Markdown
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

tsoome commented Nov 17, 2025

Copy link
Copy Markdown
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.

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

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 
@behlendorf

Copy link
Copy Markdown
Contributor Author

I added a "Smatch results log" section. It simply greps out of the build log any errors or warning.

I can't see any real downside to adding this workflow, so I'm going to pull it in so folks can use it as a starting point and refine as needed to get something we're happy with.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Nov 17, 2025

@tsoome tsoome left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@behlendorf
behlendorf merged commit 06c73cf into openzfs:master Nov 17, 2025
19 checks passed
behlendorf added a commit to behlendorf/zfs that referenced this pull request Dec 10, 2025
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes openzfs#17935
kithrup pushed a commit to KlaraSystems/zfs that referenced this pull request Dec 17, 2025
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes openzfs#17935
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 11, 2026
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes openzfs#17935
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Feb 23, 2026
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes openzfs#17935
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Feb 23, 2026
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes openzfs#17935
pcd1193182 pushed a commit to KlaraSystems/zfs that referenced this pull request Apr 8, 2026
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes openzfs#17935
behlendorf added a commit that referenced this pull request Apr 15, 2026
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.

Reviewed-by: Tony Hutter 
Reviewed-by: Toomas Soome 
Signed-off-by: Brian Behlendorf 
Closes #17935
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Accepted Ready to integrate (reviewed, tested)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants