tree-wide: fix needless borrows
found and fixed via clippy Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
@ -25,7 +25,7 @@ pub struct PkgState {
|
||||
pub fn write_pkg_cache(state: &PkgState) -> Result<(), Error> {
|
||||
let serialized_state = serde_json::to_string(state)?;
|
||||
|
||||
replace_file(APT_PKG_STATE_FN, &serialized_state.as_bytes(), CreateOptions::new(), false)
|
||||
replace_file(APT_PKG_STATE_FN, serialized_state.as_bytes(), CreateOptions::new(), false)
|
||||
.map_err(|err| format_err!("Error writing package cache - {}", err))?;
|
||||
Ok(())
|
||||
}
|
||||
@ -206,7 +206,7 @@ pub fn list_installed_apt_packages<F: Fn(FilterData) -> bool>(
|
||||
drop(cache_iter);
|
||||
// also loop through missing dependencies, as they would be installed
|
||||
for pkg in depends.iter() {
|
||||
let mut iter = cache.find_by_name(&pkg);
|
||||
let mut iter = cache.find_by_name(pkg);
|
||||
let view = match iter.next() {
|
||||
Some(view) => view,
|
||||
None => continue // package not found, ignore
|
||||
|
@ -20,7 +20,7 @@ lazy_static!{
|
||||
pub fn get_pool_from_dataset(dataset: &OsStr) -> Option<&OsStr> {
|
||||
if let Some(dataset) = dataset.to_str() {
|
||||
if let Some(idx) = dataset.find('/') {
|
||||
return Some(&dataset[0..idx].as_ref());
|
||||
return Some(dataset[0..idx].as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,13 +157,13 @@ fn test_zfs_parse_list() -> Result<(), Error> {
|
||||
|
||||
let output = "";
|
||||
|
||||
let data = parse_zpool_list(&output)?;
|
||||
let data = parse_zpool_list(output)?;
|
||||
let expect = Vec::new();
|
||||
|
||||
assert_eq!(data, expect);
|
||||
|
||||
let output = "btest 427349245952 405504 427348840448 - - 0 0 1.00 ONLINE -\n";
|
||||
let data = parse_zpool_list(&output)?;
|
||||
let data = parse_zpool_list(output)?;
|
||||
let expect = vec![
|
||||
ZFSPoolInfo {
|
||||
name: "btest".to_string(),
|
||||
@ -190,7 +190,7 @@ logs
|
||||
|
||||
";
|
||||
|
||||
let data = parse_zpool_list(&output)?;
|
||||
let data = parse_zpool_list(output)?;
|
||||
let expect = vec![
|
||||
ZFSPoolInfo {
|
||||
name: String::from("rpool"),
|
||||
@ -232,7 +232,7 @@ logs - - - - - - - - -
|
||||
/dev/sda5 213674622976 0 213674622976 - - 0 0 - ONLINE
|
||||
";
|
||||
|
||||
let data = parse_zpool_list(&output)?;
|
||||
let data = parse_zpool_list(output)?;
|
||||
let expect = vec![
|
||||
ZFSPoolInfo {
|
||||
name: String::from("b-test"),
|
||||
@ -267,7 +267,7 @@ b.test 427349245952 761856 427348484096 - - 0 0 1.00 ONLINE -
|
||||
/dev/sda1 - - - - - - - - ONLINE
|
||||
";
|
||||
|
||||
let data = parse_zpool_list(&output)?;
|
||||
let data = parse_zpool_list(output)?;
|
||||
let expect = vec![
|
||||
ZFSPoolInfo {
|
||||
name: String::from("b.test"),
|
||||
|
@ -189,7 +189,7 @@ pub fn parse_zpool_status_config_tree(i: &str) -> Result<Vec<ZFSPoolVDevState>,
|
||||
}
|
||||
|
||||
fn parse_zpool_status(input: &str) -> Result<Vec<(String, String)>, Error> {
|
||||
parse_complete("zfs status output", &input, many0(parse_zpool_status_field))
|
||||
parse_complete("zfs status output", input, many0(parse_zpool_status_field))
|
||||
}
|
||||
|
||||
pub fn vdev_list_to_tree(vdev_list: &[ZFSPoolVDevState]) -> Result<Value, Error> {
|
||||
@ -220,7 +220,7 @@ where
|
||||
};
|
||||
|
||||
for item in items {
|
||||
let (node, node_level) = to_node(&item);
|
||||
let (node, node_level) = to_node(item);
|
||||
let vdev_level = 1 + node_level;
|
||||
let mut node = match node {
|
||||
Value::Object(map) => map,
|
||||
@ -373,7 +373,7 @@ pub fn zpool_status(pool: &str) -> Result<Vec<(String, String)>, Error> {
|
||||
fn test_parse(output: &str) -> Result<(), Error> {
|
||||
let mut found_config = false;
|
||||
|
||||
for (k, v) in parse_zpool_status(&output)? {
|
||||
for (k, v) in parse_zpool_status(output)? {
|
||||
println!("<{}> => '{}'", k, v);
|
||||
if k == "config" {
|
||||
let vdev_list = parse_zpool_status_config_tree(&v)?;
|
||||
|
@ -125,7 +125,7 @@ pub fn parse_systemd_mount(filename: &str) -> Result<SectionConfigData, Error> {
|
||||
}
|
||||
|
||||
fn save_systemd_config(config: &SectionConfig, filename: &str, data: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = config.write(filename, &data)?;
|
||||
let raw = config.write(filename, data)?;
|
||||
|
||||
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0644);
|
||||
// set the correct owner/group/permissions while saving file, owner(rw) = root
|
||||
|
Reference in New Issue
Block a user