From b39b77aa5a19667d7e253e4c4948c90c667ae919 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Fri, 23 Sep 2022 23:43:33 -0400 Subject: [PATCH] meta: appease clippy --- client/src/util.rs | 3 +++ hostsfile/src/lib.rs | 2 +- server/src/db/mod.rs | 2 +- server/src/initialize.rs | 4 ++-- server/src/main.rs | 6 +++--- wireguard-control/src/backends/userspace.rs | 2 +- wireguard-control/src/key.rs | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/client/src/util.rs b/client/src/util.rs index 58bb9a6..3d6ed1a 100644 --- a/client/src/util.rs +++ b/client/src/util.rs @@ -211,10 +211,12 @@ impl<'a> Api<'a> { Self { agent, server } } + #[allow(clippy::result_large_err)] pub fn http(&self, verb: &str, endpoint: &str) -> Result { self.request::<(), _>(verb, endpoint, None) } + #[allow(clippy::result_large_err)] pub fn http_form( &self, verb: &str, @@ -224,6 +226,7 @@ impl<'a> Api<'a> { self.request(verb, endpoint, Some(form)) } + #[allow(clippy::result_large_err)] fn request( &self, verb: &str, diff --git a/hostsfile/src/lib.rs b/hostsfile/src/lib.rs index 8d3c702..6d0de6a 100644 --- a/hostsfile/src/lib.rs +++ b/hostsfile/src/lib.rs @@ -266,7 +266,7 @@ impl HostsBuilder { fn write_and_swap(temp_path: &Path, hosts_path: &Path, contents: &[u8]) -> io::Result<()> { // Copy the file we plan on modifying so its permissions and metadata are preserved. - std::fs::copy(&hosts_path, &temp_path)?; + std::fs::copy(hosts_path, temp_path)?; Self::write_clobber(temp_path, contents)?; std::fs::rename(temp_path, hosts_path)?; Ok(()) diff --git a/server/src/db/mod.rs b/server/src/db/mod.rs index 21ae8c9..9caa309 100644 --- a/server/src/db/mod.rs +++ b/server/src/db/mod.rs @@ -28,7 +28,7 @@ pub fn auto_migrate(conn: &rusqlite::Connection) -> Result<(), rusqlite::Error> } if old_version != CURRENT_VERSION { - conn.pragma_update(None, "user_version", &CURRENT_VERSION)?; + conn.pragma_update(None, "user_version", CURRENT_VERSION)?; log::info!( "migrated db version from {} to {}", old_version, diff --git a/server/src/initialize.rs b/server/src/initialize.rs index e6b6b67..d05c3ff 100644 --- a/server/src/initialize.rs +++ b/server/src/initialize.rs @@ -16,11 +16,11 @@ fn create_database>( database_path: P, ) -> Result> { let conn = Connection::open(&database_path)?; - conn.pragma_update(None, "foreign_keys", &1)?; + conn.pragma_update(None, "foreign_keys", 1)?; conn.execute(db::peer::CREATE_TABLE_SQL, params![])?; conn.execute(db::association::CREATE_TABLE_SQL, params![])?; conn.execute(db::cidr::CREATE_TABLE_SQL, params![])?; - conn.pragma_update(None, "user_version", &db::CURRENT_VERSION)?; + conn.pragma_update(None, "user_version", db::CURRENT_VERSION)?; log::debug!("set database version to db::CURRENT_VERSION"); Ok(conn) diff --git a/server/src/main.rs b/server/src/main.rs index 88c4a3e..bc16751 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -199,7 +199,7 @@ impl ConfigFile { path.display() ); } - Ok(toml::from_slice(&std::fs::read(&path).with_path(path)?)?) + Ok(toml::from_slice(&std::fs::read(path).with_path(path)?)?) } } @@ -303,7 +303,7 @@ fn open_database_connection( let conn = Connection::open(&database_path)?; // Foreign key constraints aren't on in SQLite by default. Enable. - conn.pragma_update(None, "foreign_keys", &1)?; + conn.pragma_update(None, "foreign_keys", 1)?; db::auto_migrate(&conn)?; Ok(conn) } @@ -656,7 +656,7 @@ fn get_listener(addr: SocketAddr, interface: &InterfaceName) -> Result Result { - let listener = TcpListener::bind(&addr)?; + let listener = TcpListener::bind(addr)?; listener.set_nonblocking(true)?; Ok(listener) } diff --git a/wireguard-control/src/backends/userspace.rs b/wireguard-control/src/backends/userspace.rs index 7cf1194..6543657 100644 --- a/wireguard-control/src/backends/userspace.rs +++ b/wireguard-control/src/backends/userspace.rs @@ -282,7 +282,7 @@ fn start_userspace_wireguard(iface: &InterfaceName) -> io::Result { "WG_TUN_NAME_FILE", &format!("{}/{}.name", VAR_RUN_PATH, iface), ) - .args(&["utun"]) + .args(["utun"]) .output()? }; if !output.status.success() { diff --git a/wireguard-control/src/key.rs b/wireguard-control/src/key.rs index 5c696ac..69ed6d1 100644 --- a/wireguard-control/src/key.rs +++ b/wireguard-control/src/key.rs @@ -79,7 +79,7 @@ impl Key { /// Converts the key to a standardized base64 representation, as used by the `wg` utility and `wg-quick`. pub fn to_base64(&self) -> String { - base64::encode(&self.0) + base64::encode(self.0) } /// Converts a base64 representation of the key to the raw bytes.