Skip to content

Commit

Permalink
Fix cargo clippy warnings for android for ios
Browse files Browse the repository at this point in the history
Errors:

 warning: unused imports: `ipaddr_to_sockaddr`, `sockaddr_union`
  --> src/platform/posix/mod.rs:18:27
   |
18 | pub(crate) use sockaddr::{ipaddr_to_sockaddr, sockaddr_union};
   |                           ^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: function `ipaddr_to_sockaddr` is never used
  --> src/platform/posix/sockaddr.rs:63:15
   |
63 | pub unsafe fn ipaddr_to_sockaddr<T>(
   |               ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

error: this expression creates a reference which is immediately dereferenced by the compiler
  --> src/platform/android/mod.rs:29:17
   |
29 |     Device::new(&configuration)
   |                 ^^^^^^^^^^^^^^ help: change this to: `configuration`

error: this expression creates a reference which is immediately dereferenced by the compiler
  --> src/platform/ios/mod.rs:58:17
   |
58 |     Device::new(&configuration)
   |                 ^^^^^^^^^^^^^^ help: change this to: `configuration`
  • Loading branch information
kp-mariappan-ramasamy committed Jul 23, 2024
1 parent 5840f65 commit d78a91b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/platform/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ pub struct PlatformConfig;

/// Create a TUN device with the given name.
pub fn create(configuration: &Configuration) -> Result<Device> {
Device::new(&configuration)
Device::new(configuration)
}
2 changes: 1 addition & 1 deletion src/platform/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ impl PlatformConfig {

/// Create a TUN device with the given name.
pub fn create(configuration: &Configuration) -> Result<Device> {
Device::new(&configuration)
Device::new(configuration)
}
6 changes: 5 additions & 1 deletion src/platform/posix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
//! POSIX compliant support.

mod sockaddr;
pub(crate) use sockaddr::{ipaddr_to_sockaddr, sockaddr_union};
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
pub(crate) use sockaddr::sockaddr_union;

#[cfg(any(target_os = "linux", target_os = "macos"))]
pub(crate) use sockaddr::ipaddr_to_sockaddr;

mod fd;
pub(crate) use self::fd::Fd;
Expand Down
3 changes: 2 additions & 1 deletion src/platform/posix/sockaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ fn rs_addr_to_sockaddr(addr: std::net::SocketAddr) -> sockaddr_union {

/// # Safety
/// Fill the `addr` with the `src_addr` and `src_port`, the `size` should be the size of overwriting
pub unsafe fn ipaddr_to_sockaddr<T>(
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub(crate) unsafe fn ipaddr_to_sockaddr<T>(
src_addr: T,
src_port: u16,
addr: &mut libc::sockaddr,
Expand Down

0 comments on commit d78a91b

Please sign in to comment.