Prechádzať zdrojové kódy

src: fix all warnings from clippy, one way or another

Now all warnings printed by `cargo clippy` would come from new commits,
and should ideally be fixed (or if needed, muted) before merging.
Quentin Monnet 8 rokov pred
rodič
commit
c63bd3411a
4 zmenil súbory, kde vykonal 9 pridanie a 0 odobranie
  1. 2 0
      src/ebpf.rs
  2. 1 0
      src/insn_builder.rs
  3. 2 0
      src/jit.rs
  4. 4 0
      src/lib.rs

+ 2 - 0
src/ebpf.rs

@@ -164,6 +164,8 @@ 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(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`.

+ 1 - 0
src/insn_builder.rs

@@ -96,6 +96,7 @@ impl<'i, I: Instruction> IntoBytes for &'i I {
 }
 
 /// BPF instruction stack in byte representation
+#[derive(Default)]
 pub struct BpfCode {
     instructions: Vec<u8>
 }

+ 2 - 0
src/jit.rs

@@ -298,6 +298,7 @@ fn emit_load_imm(jit: &mut JitMemory, dst: u8, imm: i64) {
 // Store register src to [dst + offset]
 #[inline]
 fn emit_store(jit: &mut JitMemory, size: OperandSize, src: u8, dst: u8, offset: i32) {
+    #[allow(single_match)]
     match size {
         OperandSize::S16 => emit1(jit, 0x66), // 16-bit override
         _ => {},
@@ -326,6 +327,7 @@ fn emit_store(jit: &mut JitMemory, size: OperandSize, src: u8, dst: u8, offset:
 // Store immediate to [dst + offset]
 #[inline]
 fn emit_store_imm32(jit: &mut JitMemory, size: OperandSize, dst: u8, offset: i32, imm: i32) {
+    #[allow(single_match)]
     match size {
         OperandSize::S16 => emit1(jit, 0x66), // 16-bit override
         _ => {},

+ 4 - 0
src/lib.rs

@@ -15,6 +15,8 @@
 
 #![warn(missing_docs)]
 
+#![cfg_attr(feature = "cargo-clippy", allow(doc_markdown, match_same_arms))]
+
 use std::u32;
 use std::collections::HashMap;
 
@@ -223,6 +225,8 @@ impl<'a> EbpfVmMbuff<'a> {
     /// let res = vm.prog_exec(mem, &mut mbuff);
     /// assert_eq!(res, 0x2211);
     /// ```
+    #[allow(unknown_lints)]
+    #[allow(cyclomatic_complexity)]
     pub fn prog_exec(&self, mem: &[u8], mbuff: &[u8]) -> u64 {
         const U32MAX: u64 = u32::MAX as u64;