From fac7cce224ca38e88e30ed0f16b0e93782625b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Mon, 3 Jun 2024 16:57:27 +0200 Subject: [PATCH 1/2] fix: unbreak subvolume commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was a stupid mistake by me, "fixing" more than what clippy told me to. `p` is already a reference and we should not use the addr of it. Fixes: 96a3462 ("refactor: casting-related `clippy::pedantic` fixes") Signed-off-by: Thomas Mühlbacher --- src/wrappers/handle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wrappers/handle.rs b/src/wrappers/handle.rs index b5b49628..b9a4a63d 100644 --- a/src/wrappers/handle.rs +++ b/src/wrappers/handle.rs @@ -1,4 +1,4 @@ -use std::{path::Path, ptr}; +use std::path::Path; use bch_bindgen::c::{ bcache_fs_close, bcache_fs_open, bch_ioctl_subvolume, bchfs_handle, BCH_IOCTL_SUBVOLUME_CREATE, @@ -42,7 +42,7 @@ pub enum BcachefsIoctlPayload { impl From<&BcachefsIoctlPayload> for *const libc::c_void { fn from(value: &BcachefsIoctlPayload) -> Self { match value { - BcachefsIoctlPayload::Subvolume(p) => ptr::addr_of!(p).cast(), + BcachefsIoctlPayload::Subvolume(p) => (p as *const bch_ioctl_subvolume).cast(), } } } From 30e16b5e15ff86b6ead0608cbd9f8bf43ab045dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Mon, 3 Jun 2024 17:02:27 +0200 Subject: [PATCH 2/2] fix: avoid `addr_of` if we already use a reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's kind of stupid to use this macro if we have to deref the parameter first. I was too enthusiastic about using this macro instead of `as` because it's nicer to read (imo). Signed-off-by: Thomas Mühlbacher --- src/key.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/key.rs b/src/key.rs index 558c5b91..54959d6e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -11,7 +11,7 @@ use std::{ use anyhow::{anyhow, ensure, Result}; use bch_bindgen::{ bcachefs::{self, bch_key, bch_sb_handle}, - c::bch2_chacha_encrypt_key, + c::{bch2_chacha_encrypt_key, bch_sb_field_crypt}, keyutils::{self, keyctl_search}, }; use byteorder::{LittleEndian, ReadBytesExt}; @@ -66,7 +66,7 @@ impl KeyHandle { let bch_key_magic = BCH_KEY_MAGIC.as_bytes().read_u64::().unwrap(); let crypt = sb.sb().crypt().unwrap(); - let crypt_ptr = ptr::addr_of!(*crypt).cast_mut(); + let crypt_ptr = (crypt as *const bch_sb_field_crypt).cast_mut(); let mut output: bch_key = unsafe { bcachefs::derive_passphrase(crypt_ptr, passphrase.get().as_ptr()) };