diff --git a/Cargo.toml b/Cargo.toml index f5dc9e22..b11998c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,7 +113,7 @@ xz2 = { version = "0.1.7", default-features = false } [workspace.lints.clippy] all = "warn" as_ptr_cast_mut = "warn" -#as_underscore = "warn" +as_underscore = "warn" cast_lossless = "warn" #cast_possible_truncation = "warn" #cast_possible_wrap = "warn" diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs index dc778181..7a6a0ef2 100644 --- a/aya/src/sys/bpf.rs +++ b/aya/src/sys/bpf.rs @@ -192,7 +192,7 @@ pub(crate) fn bpf_load_program( u.log_size = log_buf.len() as u32; } if let Some(v) = aya_attr.attach_btf_obj_fd { - u.__bindgen_anon_1.attach_btf_obj_fd = v.as_raw_fd() as _; + u.__bindgen_anon_1.attach_btf_obj_fd = v.as_raw_fd() as u32; } if let Some(v) = aya_attr.attach_prog_fd { u.__bindgen_anon_1.attach_prog_fd = v.as_raw_fd() as u32; @@ -598,8 +598,8 @@ pub(crate) fn bpf_prog_get_info_by_fd( // extra space is not all-zero bytes. bpf_obj_get_info_by_fd(fd, |info: &mut bpf_prog_info| { if !map_ids.is_empty() { - info.nr_map_ids = map_ids.len() as _; - info.map_ids = map_ids.as_mut_ptr() as _; + info.nr_map_ids = map_ids.len() as u32; + info.map_ids = map_ids.as_mut_ptr() as u64; } }) } @@ -645,8 +645,8 @@ pub(crate) fn btf_obj_get_info_by_fd( buf: &mut [u8], ) -> Result { bpf_obj_get_info_by_fd(fd, |info: &mut bpf_btf_info| { - info.btf = buf.as_mut_ptr() as _; - info.btf_size = buf.len() as _; + info.btf = buf.as_mut_ptr() as u64; + info.btf_size = buf.len() as u32; }) } @@ -800,8 +800,8 @@ where let mut attr = unsafe { mem::zeroed::() }; let u = unsafe { &mut attr.__bindgen_anon_3 }; - let mov64_imm = (BPF_ALU64 | BPF_MOV | BPF_K) as _; - let exit = (BPF_JMP | BPF_EXIT) as _; + let mov64_imm = (BPF_ALU64 | BPF_MOV | BPF_K) as u8; + let exit = (BPF_JMP | BPF_EXIT) as u8; let insns = [new_insn(mov64_imm, 0, 0, 0, 0), new_insn(exit, 0, 0, 0, 0)]; let gpl = c"GPL"; @@ -879,17 +879,17 @@ pub(crate) fn is_probe_read_kernel_supported() -> bool { let mut attr = unsafe { mem::zeroed::() }; let u = unsafe { &mut attr.__bindgen_anon_3 }; - let mov64_reg = (BPF_ALU64 | BPF_MOV | BPF_X) as _; - let add64_imm = (BPF_ALU64 | BPF_ADD | BPF_K) as _; - let mov64_imm = (BPF_ALU64 | BPF_MOV | BPF_K) as _; - let call = (BPF_JMP | BPF_CALL) as _; - let exit = (BPF_JMP | BPF_EXIT) as _; + let mov64_reg = (BPF_ALU64 | BPF_MOV | BPF_X) as u8; + let add64_imm = (BPF_ALU64 | BPF_ADD | BPF_K) as u8; + let mov64_imm = (BPF_ALU64 | BPF_MOV | BPF_K) as u8; + let call = (BPF_JMP | BPF_CALL) as u8; + let exit = (BPF_JMP | BPF_EXIT) as u8; let insns = [ new_insn(mov64_reg, 1, 10, 0, 0), new_insn(add64_imm, 1, 0, 0, -8), new_insn(mov64_imm, 2, 0, 0, 8), new_insn(mov64_imm, 3, 0, 0, 0), - new_insn(call, 0, 0, 0, BPF_FUNC_probe_read_kernel as _), + new_insn(call, 0, 0, 0, BPF_FUNC_probe_read_kernel as i32), new_insn(exit, 0, 0, 0, 0), ]; @@ -946,12 +946,12 @@ pub(crate) fn is_bpf_global_data_supported() -> bool { ); if let Ok(map) = map { - let ld_map_value = (BPF_LD | BPF_DW | BPF_IMM) as _; - let pseudo_map_value = BPF_PSEUDO_MAP_VALUE as _; + let ld_map_value = (BPF_LD | BPF_DW | BPF_IMM) as u8; + let pseudo_map_value = BPF_PSEUDO_MAP_VALUE as u8; let fd = map.fd().as_fd().as_raw_fd(); - let st_mem = (BPF_ST | BPF_DW | BPF_MEM) as _; - let mov64_imm = (BPF_ALU64 | BPF_MOV | BPF_K) as _; - let exit = (BPF_JMP | BPF_EXIT) as _; + let st_mem = (BPF_ST | BPF_DW | BPF_MEM) as u8; + let mov64_imm = (BPF_ALU64 | BPF_MOV | BPF_K) as u8; + let exit = (BPF_JMP | BPF_EXIT) as u8; let insns = [ new_insn(ld_map_value, 1, pseudo_map_value, 0, fd), new_insn(0, 0, 0, 0, 0), @@ -976,10 +976,10 @@ pub(crate) fn is_bpf_cookie_supported() -> bool { let mut attr = unsafe { mem::zeroed::() }; let u = unsafe { &mut attr.__bindgen_anon_3 }; - let call = (BPF_JMP | BPF_CALL) as _; - let exit = (BPF_JMP | BPF_EXIT) as _; + let call = (BPF_JMP | BPF_CALL) as u8; + let exit = (BPF_JMP | BPF_EXIT) as u8; let insns = [ - new_insn(call, 0, 0, 0, BPF_FUNC_get_attach_cookie as _), + new_insn(call, 0, 0, 0, BPF_FUNC_get_attach_cookie as i32), new_insn(exit, 0, 0, 0, 0), ]; diff --git a/ebpf/aya-ebpf/src/helpers.rs b/ebpf/aya-ebpf/src/helpers.rs index e49d24a9..6e23f1d3 100644 --- a/ebpf/aya-ebpf/src/helpers.rs +++ b/ebpf/aya-ebpf/src/helpers.rs @@ -819,7 +819,7 @@ pub unsafe fn bpf_printk_impl( fmt_ptr, fmt_size, args.as_ptr().cast(), - (NUM_ARGS * 8) as _, + (NUM_ARGS * 8) as u32, ) }, } diff --git a/test/integration-ebpf/src/sk_storage.rs b/test/integration-ebpf/src/sk_storage.rs index c6da2876..a625c90b 100644 --- a/test/integration-ebpf/src/sk_storage.rs +++ b/test/integration-ebpf/src/sk_storage.rs @@ -33,7 +33,7 @@ pub(crate) fn sk_storage_connect4(ctx: SockAddrContext) -> i32 { } } - sk_action::SK_PASS as _ + sk_action::SK_PASS as i32 } #[cgroup_sock_addr(connect6)] @@ -74,5 +74,5 @@ pub(crate) fn sk_storage_connect6(ctx: SockAddrContext) -> i32 { } } - sk_action::SK_PASS as _ + sk_action::SK_PASS as i32 }