Преглед на файлове

src: Remove presumably unused Clippy directives

"cargo clippy" seems to pass just fine without most of the Clippy
directives we have in the code. I believe some issues have been fixed
over time, some directives were unnecessarily added when copy-pasting
into a new file, and for the rest I'm not sure; likely, Clippy's
behaviour has changed somewhat over time.

Anyway, let's remove these if they are not necessary.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
Quentin Monnet преди 8 месеца
родител
ревизия
b4079fedfc
променени са 12 файла, в които са добавени 3 реда и са изтрити 42 реда
  1. 0 2
      examples/allowed_memory.rs
  2. 0 2
      examples/load_elf.rs
  3. 1 1
      examples/rbpf_plugin.rs
  4. 0 2
      src/ebpf.rs
  5. 0 12
      src/interpreter.rs
  6. 2 0
      src/jit.rs
  7. 0 13
      src/lib.rs
  8. 0 2
      tests/assembler.rs
  9. 0 1
      tests/cranelift.rs
  10. 0 4
      tests/misc.rs
  11. 0 1
      tests/ubpf_jit_x86_64.rs
  12. 0 2
      tests/ubpf_vm.rs

+ 0 - 2
examples/allowed_memory.rs

@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
 // Copyright 2024 Akenes SA <wouter.dullaert@exoscale.ch>
 
-#![allow(clippy::unreadable_literal)]
-
 extern crate elf;
 use std::{iter::FromIterator, ptr::addr_of};
 

+ 0 - 2
examples/load_elf.rs

@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
 // Copyright 2016 6WIND S.A. <quentin.monnet@6wind.com>
 
-#![allow(clippy::unreadable_literal)]
-
 extern crate elf;
 use std::path::PathBuf;
 

+ 1 - 1
examples/rbpf_plugin.rs

@@ -15,7 +15,7 @@ fn _unwind(a: u64, _b: u64, _c: u64, _d: u64, _e: u64) -> u64
 // It reads the program from stdin.
 fn main() {
     let mut args: Vec<String> = std::env::args().collect();
-    #[allow(unused_mut)] // In no_std the jit variable isn't mutated.
+    #[cfg_attr(not(feature = "std"), allow(unused_mut))] // In no_std the jit variable isn't mutated.
     let mut jit : bool = false;
     let mut cranelift : bool = false;
     let mut program_text = String::new();

+ 0 - 2
src/ebpf.rs

@@ -173,8 +173,6 @@ pub const LD_IND_W   : u8 = BPF_LD    | BPF_IND | BPF_W;
 /// BPF opcode: `ldinddw src, dst, imm`.
 pub const LD_IND_DW  : u8 = BPF_LD    | BPF_IND | BPF_DW;
 
-#[allow(unknown_lints)]
-#[allow(clippy::eq_op)]
 /// BPF opcode: `lddw dst, imm` /// `dst = imm`.
 pub const LD_DW_IMM  : u8 = BPF_LD    | BPF_IMM | BPF_DW;
 /// BPF opcode: `ldxb dst, [src + off]` /// `dst = (src + off) as u8`.

+ 0 - 12
src/interpreter.rs

@@ -43,8 +43,6 @@ fn check_mem(
     )))
 }
 
-#[allow(unknown_lints)]
-#[allow(cyclomatic_complexity)]
 pub fn execute_program(
     prog_: Option<&[u8]>,
     mem: &[u8],
@@ -147,25 +145,21 @@ pub fn execute_program(
 
             // BPF_LDX class
             ebpf::LD_B_REG   => reg[_dst] = unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_src] as *const u8).wrapping_offset(insn.off as isize);
                 check_mem_load(x as u64, 1, insn_ptr)?;
                 x.read_unaligned() as u64
             },
             ebpf::LD_H_REG   => reg[_dst] = unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_src] as *const u8).wrapping_offset(insn.off as isize) as *const u16;
                 check_mem_load(x as u64, 2, insn_ptr)?;
                 x.read_unaligned() as u64
             },
             ebpf::LD_W_REG   => reg[_dst] = unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_src] as *const u8).wrapping_offset(insn.off as isize) as *const u32;
                 check_mem_load(x as u64, 4, insn_ptr)?;
                 x.read_unaligned() as u64
             },
             ebpf::LD_DW_REG  => reg[_dst] = unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_src] as *const u8).wrapping_offset(insn.off as isize) as *const u64;
                 check_mem_load(x as u64, 8, insn_ptr)?;
                 x.read_unaligned()
@@ -178,19 +172,16 @@ pub fn execute_program(
                 x.write_unaligned(insn.imm as u8);
             },
             ebpf::ST_H_IMM   => unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_dst] as *const u8).wrapping_offset(insn.off as isize) as *mut u16;
                 check_mem_store(x as u64, 2, insn_ptr)?;
                 x.write_unaligned(insn.imm as u16);
             },
             ebpf::ST_W_IMM   => unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_dst] as *const u8).wrapping_offset(insn.off as isize) as *mut u32;
                 check_mem_store(x as u64, 4, insn_ptr)?;
                 x.write_unaligned(insn.imm as u32);
             },
             ebpf::ST_DW_IMM  => unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_dst] as *const u8).wrapping_offset(insn.off as isize) as *mut u64;
                 check_mem_store(x as u64, 8, insn_ptr)?;
                 x.write_unaligned(insn.imm as u64);
@@ -203,19 +194,16 @@ pub fn execute_program(
                 x.write_unaligned(reg[_src] as u8);
             },
             ebpf::ST_H_REG   => unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_dst] as *const u8).wrapping_offset(insn.off as isize) as *mut u16;
                 check_mem_store(x as u64, 2, insn_ptr)?;
                 x.write_unaligned(reg[_src] as u16);
             },
             ebpf::ST_W_REG   => unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_dst] as *const u8).wrapping_offset(insn.off as isize) as *mut u32;
                 check_mem_store(x as u64, 4, insn_ptr)?;
                 x.write_unaligned(reg[_src] as u32);
             },
             ebpf::ST_DW_REG  => unsafe {
-                #[allow(clippy::cast_ptr_alignment)]
                 let x = (reg[_dst] as *const u8).wrapping_offset(insn.off as isize) as *mut u64;
                 check_mem_store(x as u64, 8, insn_ptr)?;
                 x.write_unaligned(reg[_src]);

+ 2 - 0
src/jit.rs

@@ -5,6 +5,8 @@
 // Copyright 2016 6WIND S.A. <quentin.monnet@6wind.com>
 //      (Translation to Rust, MetaBuff addition)
 
+#![allow(clippy::single_match)]
+
 use std::alloc;
 use std::mem;
 use std::collections::HashMap;

+ 0 - 13
src/lib.rs

@@ -10,19 +10,6 @@
 )]
 // Test examples from README.md as part as doc tests.
 #![doc = include_str!("../README.md")]
-#![warn(missing_docs)]
-// There are unused mut warnings due to unsafe code.
-#![allow(unused_mut)]
-// Allows old-style clippy
-#![allow(renamed_and_removed_lints)]
-#![allow(
-    clippy::redundant_field_names,
-    clippy::single_match,
-    clippy::cast_lossless,
-    clippy::doc_markdown,
-    clippy::match_same_arms,
-    clippy::unreadable_literal
-)]
 // Configures the crate to be `no_std` when `std` feature is disabled.
 #![cfg_attr(not(feature = "std"), no_std)]
 

+ 0 - 2
tests/assembler.rs

@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
 // Copyright 2017 Rich Lane <lanerl@gmail.com>
 
-#![allow(clippy::unreadable_literal)]
-
 extern crate rbpf;
 mod common;
 

+ 0 - 1
tests/cranelift.rs

@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
-#![allow(clippy::unreadable_literal)]
 #![cfg(feature = "cranelift")]
 
 extern crate rbpf;

+ 0 - 4
tests/misc.rs

@@ -1,10 +1,6 @@
 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
 // Copyright 2016 6WIND S.A. <quentin.monnet@6wind.com>
 
-// There are unused mut warnings due to unsafe code.
-#![allow(unused_mut)]
-#![allow(clippy::unreadable_literal)]
-
 // This crate would be needed to load bytecode from a BPF-compiled object file. Since the crate
 // is not used anywhere else in the library, it is deactivated: we do not want to load and compile
 // it just for the tests. If you want to use it, do not forget to add the following

+ 0 - 1
tests/ubpf_jit_x86_64.rs

@@ -16,7 +16,6 @@
 
 // These are unit tests for the eBPF JIT compiler.
 
-#![allow(clippy::unreadable_literal)]
 #![cfg(all(not(windows), feature = "std"))]
 
 extern crate rbpf;

+ 0 - 2
tests/ubpf_vm.rs

@@ -16,8 +16,6 @@
 
 // These are unit tests for the eBPF interpreter.
 
-#![allow(clippy::unreadable_literal)]
-
 extern crate rbpf;
 mod common;