A request for comments (RFC) patch series was sent out today for providing Klint integration with the Linux kernel. Klint is a new linting tool written in the Rust programming language that helps with static code analysis for errors/bugs as well as code styling inconsistencies.
Gary Guo posted the RFC patches for Klint integration into the Linux kernel. Gary has been developing Klint since 2022 and grew in scope over time. He explained in the announcement:
“Klint is a linting tool (in the form of a custom Rust compiler driver, similar to how Clippy works) that I have been working on since 2022. It was initially created to help lint on code that can trigger panics on allocation failure; this feature has been long obsolete after we started vendoring alloc crate and subsequently replacing it with a custom implementation, but over time it also gains some other useful lints.
Lints that are considered ready currently:
* Items available via kernel prelude but imported via other means
* build_error/build_assert calls not being optimized out (klint will provide you a backtrace to ease analysis, as opposed to just a linker error).
* Stack frames larger than desired (configured via CONFIG_FRAME_WARN).The kernel is not currently lint clean. I’ve already sent out a series to fix the prelude imports; there is a true-positive with Nova-core’s Cmdq::new method’s excessive stack usage which needs fixing.
Many of you may have also heard about klint’s ability to perform locking rule checks, however I did not consider it ready (due to false positives and inability to analysis some code patterns), so it is not enabled in the series.”
More details for those interested can be found via the patch series on the mailing list.
The current Klint code itself is hosted via Rust-for-Linux/klint on GitHub.
