From af93866c415016ec553693aca000a3db547cee4c Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Sun, 6 Oct 2019 11:15:01 -0600 Subject: [PATCH] Add more clippy lints --- clippy.sh | 3 +++ src/lib.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/clippy.sh b/clippy.sh index a858da52..67ab40db 100755 --- a/clippy.sh +++ b/clippy.sh @@ -8,6 +8,9 @@ rustup update "${RUSTUP_TOOLCHAIN}" rustup component add clippy --toolchain "${RUSTUP_TOOLCHAIN}" rustup component add rust-src --toolchain "${RUSTUP_TOOLCHAIN}" +# Cause recompilation +touch src/lib.rs + export RUST_TARGET_PATH="${PWD}/targets" export RUSTFLAGS="-C soft-float -C debuginfo=2" xargo clippy --lib --release --target x86_64-unknown-none diff --git a/src/lib.rs b/src/lib.rs index e874b233..9b1c8c49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,10 +19,23 @@ #![allow(clippy::too_many_arguments)] // There is no harm in this being done #![allow(clippy::useless_format)] + // TODO: address ocurrances and then deny #![warn(clippy::not_unsafe_ptr_arg_deref)] // TODO: address ocurrances and then deny #![warn(clippy::cast_ptr_alignment)] +// Indexing a slice can cause panics and that is something we always want to avoid +// in kernel code. Use .get and return an error instead +// TODO: address ocurrances and then deny +#![warn(clippy::indexing_slicing)] +// Overflows are very, very bad in kernel code as it may provide an attack vector for +// userspace applications, and it is only checked in debug builds +// TODO: address ocurrances and then deny +#![warn(clippy::integer_arithmetic)] +// Avoid panicking in the kernel without information about the panic. Use expect +// TODO: address ocurrances and then deny +#![warn(clippy::result_unwrap_used)] + // This is usually a serious issue - a missing import of a define where it is interpreted // as a catch-all variable in a match, for example #![deny(unreachable_patterns)] -- GitLab