Page MenuHomeFreeBSD

kmod: build with INVARIANTS for clang-analyzer
Needs ReviewPublic

Authored by kevans on Nov 5 2021, 10:58 PM.

Details

Reviewers
mjg
emaste
jhb
Summary

INVARIANTS sometimes informally documents some of the less obvious
assumptions that trip up clang --analyze with a path into a __dead2
function. Turning it on doesn't affect much else, so let's do it.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 42622
Build 39510: arc lint + arc unit

Event Timeline

This is going to hide a host of write-only or straight up unused vars when the kernel is built without invariants.

If anything the thing to do here is to rework all the assert macros to expand to __builtin_unreachable if the asserted condition does not hold. However, that's quite a churn.

In D32861#741789, @mjg wrote:

This is going to hide a host of write-only or straight up unused vars when the kernel is built without invariants.

If anything the thing to do here is to rework all the assert macros to expand to __builtin_unreachable if the asserted condition does not hold. However, that's quite a churn.

[Phabricator is magic]. I don't see how you intend to do that, either, if the very act of observing the write-only var is enough to kill it.