refactor: manually fix remaining clippy lints

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This commit is contained in:
Thomas Mühlbacher 2024-05-22 22:21:31 +02:00
parent 3488d4f15f
commit 3882d1b1e4
2 changed files with 6 additions and 5 deletions

View File

@ -4,7 +4,7 @@ use std::collections::HashMap;
use clap::Parser; use clap::Parser;
use uuid::Uuid; use uuid::Uuid;
use std::io::{stdout, IsTerminal}; use std::io::{stdout, IsTerminal};
use std::path::PathBuf; use std::path::{Path, PathBuf};
use std::{fs, str, env}; use std::{fs, str, env};
use crate::key; use crate::key;
use crate::key::UnlockPolicy; use crate::key::UnlockPolicy;
@ -101,11 +101,11 @@ fn do_mount(
mount_inner(device, target, "bcachefs", mountflags, data) mount_inner(device, target, "bcachefs", mountflags, data)
} }
fn read_super_silent(path: &std::path::PathBuf) -> anyhow::Result<bch_sb_handle> { fn read_super_silent(path: impl AsRef<Path>) -> anyhow::Result<bch_sb_handle> {
let mut opts = bcachefs::bch_opts::default(); let mut opts = bcachefs::bch_opts::default();
opt_set!(opts, noexcl, 1); opt_set!(opts, noexcl, 1);
bch_bindgen::sb_io::read_super_silent(path, opts) bch_bindgen::sb_io::read_super_silent(path.as_ref(), opts)
} }
fn device_property_map(dev: &udev::Device) -> HashMap<String, String> { fn device_property_map(dev: &udev::Device) -> HashMap<String, String> {
@ -158,7 +158,7 @@ fn get_super_blocks(
Ok(devices Ok(devices
.iter() .iter()
.filter_map(|dev| { .filter_map(|dev| {
read_super_silent(&PathBuf::from(dev)) read_super_silent(PathBuf::from(dev))
.ok() .ok()
.map(|sb| (PathBuf::from(dev), sb)) .map(|sb| (PathBuf::from(dev), sb))
}) })
@ -203,6 +203,7 @@ fn get_devices_by_uuid(
get_super_blocks(uuid, &devices) get_super_blocks(uuid, &devices)
} }
#[allow(clippy::type_complexity)]
fn get_uuid_for_dev_node( fn get_uuid_for_dev_node(
udev_bcachefs: &HashMap<String, Vec<String>>, udev_bcachefs: &HashMap<String, Vec<String>>,
device: &std::path::PathBuf, device: &std::path::PathBuf,

View File

@ -98,7 +98,7 @@ fn ask_for_passphrase(sb: &bch_sb_handle) -> anyhow::Result<()> {
} }
const BCH_KEY_MAGIC: &str = "bch**key"; const BCH_KEY_MAGIC: &str = "bch**key";
fn unlock_master_key(sb: &bch_sb_handle, passphrase: &String) -> anyhow::Result<()> { fn unlock_master_key(sb: &bch_sb_handle, passphrase: &str) -> anyhow::Result<()> {
use bch_bindgen::bcachefs::{self, bch2_chacha_encrypt_key, bch_encrypted_key, bch_key}; use bch_bindgen::bcachefs::{self, bch2_chacha_encrypt_key, bch_encrypted_key, bch_key};
use byteorder::{LittleEndian, ReadBytesExt}; use byteorder::{LittleEndian, ReadBytesExt};
use std::os::raw::c_char; use std::os::raw::c_char;