From 2859684864b890686392ea015bcaae941f18df46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Laitl?= Date: Mon, 2 Jan 2023 16:04:15 +0100 Subject: [PATCH] cargo clippy --fix --all-targets (clippy 1.66) This is exclusively (if I look correctly) redundant referencing. --- client/src/data_store.rs | 8 ++++---- hostsfile/src/lib.rs | 2 +- server/src/api/admin/association.rs | 2 +- server/src/api/admin/cidr.rs | 4 ++-- server/src/initialize.rs | 2 +- server/src/test.rs | 2 +- wireguard-control/src/backends/userspace.rs | 8 ++++---- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/src/data_store.rs b/client/src/data_store.rs index 945fd34..0fe7222 100644 --- a/client/src/data_store.rs +++ b/client/src/data_store.rs @@ -174,7 +174,7 @@ mod tests { } fn setup_basic_store(dir: &Path) { - let mut store = DataStore::open_with_path(&dir.join("peer_store.json"), true).unwrap(); + let mut store = DataStore::open_with_path(dir.join("peer_store.json"), true).unwrap(); println!("{:?}", store); assert_eq!(0, store.peers().len()); @@ -189,7 +189,7 @@ mod tests { fn test_sanity() { let dir = tempfile::tempdir().unwrap(); setup_basic_store(dir.path()); - let store = DataStore::open_with_path(&dir.path().join("peer_store.json"), false).unwrap(); + let store = DataStore::open_with_path(dir.path().join("peer_store.json"), false).unwrap(); assert_eq!(store.peers(), &*BASE_PEERS); assert_eq!(store.cidrs(), &*BASE_CIDRS); } @@ -199,7 +199,7 @@ mod tests { let dir = tempfile::tempdir().unwrap(); setup_basic_store(dir.path()); let mut store = - DataStore::open_with_path(&dir.path().join("peer_store.json"), false).unwrap(); + DataStore::open_with_path(dir.path().join("peer_store.json"), false).unwrap(); // Should work, since peer is unmodified. store.update_peers(&BASE_PEERS).unwrap(); @@ -216,7 +216,7 @@ mod tests { let dir = tempfile::tempdir().unwrap(); setup_basic_store(dir.path()); let mut store = - DataStore::open_with_path(&dir.path().join("peer_store.json"), false).unwrap(); + DataStore::open_with_path(dir.path().join("peer_store.json"), false).unwrap(); // Should work, since peer is unmodified. store.update_peers(&[]).unwrap(); diff --git a/hostsfile/src/lib.rs b/hostsfile/src/lib.rs index 6d0de6a..cd654e5 100644 --- a/hostsfile/src/lib.rs +++ b/hostsfile/src/lib.rs @@ -117,7 +117,7 @@ impl HostsBuilder { /// Inserts a new section to the system's default hosts file. If there is a section with the /// same tag name already, it will be replaced with the new list instead. pub fn write(&self) -> io::Result<()> { - self.write_to(&Self::default_path()?) + self.write_to(Self::default_path()?) } /// Returns the default hosts path based on the current OS. diff --git a/server/src/api/admin/association.rs b/server/src/api/admin/association.rs index fb037d9..d0ae660 100644 --- a/server/src/api/admin/association.rs +++ b/server/src/api/admin/association.rs @@ -49,7 +49,7 @@ mod handlers { let conn = session.context.db.lock(); let auths = DatabaseAssociation::list(&conn)?; - json_response(&auths) + json_response(auths) } pub async fn delete(id: i64, session: Session) -> Result, ServerError> { diff --git a/server/src/api/admin/cidr.rs b/server/src/api/admin/cidr.rs index 5b7ee1d..5716249 100644 --- a/server/src/api/admin/cidr.rs +++ b/server/src/api/admin/cidr.rs @@ -40,14 +40,14 @@ mod handlers { let cidr = DatabaseCidr::create(&conn, contents)?; - json_status_response(&cidr, StatusCode::CREATED) + json_status_response(cidr, StatusCode::CREATED) } pub async fn list(session: Session) -> Result, ServerError> { let conn = session.context.db.lock(); let cidrs = DatabaseCidr::list(&conn)?; - json_response(&cidrs) + json_response(cidrs) } pub async fn delete(id: i64, session: Session) -> Result, ServerError> { diff --git a/server/src/initialize.rs b/server/src/initialize.rs index d05c3ff..2c81773 100644 --- a/server/src/initialize.rs +++ b/server/src/initialize.rs @@ -178,7 +178,7 @@ pub fn init_wizard(conf: &ServerConfig, opts: InitializeOpts) -> Result<(), Erro address: our_ip, network_cidr_prefix: root_cidr.prefix_len(), }; - config.write_to_path(&config_path)?; + config.write_to_path(config_path)?; let db_init_data = DbInitData { network_name: name.to_string(), diff --git a/server/src/test.rs b/server/src/test.rs index 291f018..a03f9ec 100644 --- a/server/src/test.rs +++ b/server/src/test.rs @@ -103,7 +103,7 @@ impl Server { let interface = interface.parse().unwrap(); // Add developer CIDR and user CIDR and some peers for testing. - let db = Connection::open(&conf.database_path(&interface))?; + let db = Connection::open(conf.database_path(&interface))?; db.pragma_update(None, "foreign_keys", 1)?; assert_eq!(ADMIN_CIDR_ID, create_cidr(&db, "admin", ADMIN_CIDR)?.id); assert_eq!( diff --git a/wireguard-control/src/backends/userspace.rs b/wireguard-control/src/backends/userspace.rs index 6543657..a6dbf29 100644 --- a/wireguard-control/src/backends/userspace.rs +++ b/wireguard-control/src/backends/userspace.rs @@ -27,14 +27,14 @@ fn get_base_folder() -> io::Result { } fn get_namefile(name: &InterfaceName) -> io::Result { - Ok(get_base_folder()?.join(&format!("{}.name", name.as_str_lossy()))) + Ok(get_base_folder()?.join(format!("{}.name", name.as_str_lossy()))) } fn get_socketfile(name: &InterfaceName) -> io::Result { if cfg!(target_os = "linux") { - Ok(get_base_folder()?.join(&format!("{}.sock", name))) + Ok(get_base_folder()?.join(format!("{}.sock", name))) } else { - Ok(get_base_folder()?.join(&format!("{}.sock", resolve_tun(name)?))) + Ok(get_base_folder()?.join(format!("{}.sock", resolve_tun(name)?))) } } @@ -273,7 +273,7 @@ fn get_userspace_implementation() -> String { } fn start_userspace_wireguard(iface: &InterfaceName) -> io::Result { - let mut command = Command::new(&get_userspace_implementation()); + let mut command = Command::new(get_userspace_implementation()); let output = if cfg!(target_os = "linux") { command.args(&[iface.to_string()]).output()? } else {