Skip to content

Commit

Permalink
Remove the unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
umgefahren committed Oct 2, 2024
1 parent e656b35 commit 9fc8065
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions transports/tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,19 +722,6 @@ fn if_nametoindex(name: impl Into<Vec<u8>>) -> io::Result<u32> {
}
}

/// Returns the name of the network interface corresponding to the given interface index.
#[cfg(unix)]
fn if_indextoname(name: u32) -> io::Result<String> {
let mut buffer = [0; libc::IF_NAMESIZE];
let maybe_name = unsafe { libc::if_indextoname(name, buffer.as_mut_ptr()) };
if maybe_name.is_null() {
Err(io::Error::last_os_error())
} else {
let cstr = unsafe { std::ffi::CStr::from_ptr(maybe_name) };
Ok(cstr.to_string_lossy().into_owned())
}
}

#[cfg(not(unix))]
fn if_nametoindex(name: impl Into<Vec<u8>>) -> io::Result<u32> {

Check failure on line 726 in transports/tcp/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile on x86_64-pc-windows-msvc

unused variable: `name`
Err(io::Error::new(
Expand All @@ -743,14 +730,6 @@ fn if_nametoindex(name: impl Into<Vec<u8>>) -> io::Result<u32> {
))
}

#[cfg(not(unix))]
fn if_indextoname(name: u32) -> io::Result<String> {
Err(io::Error::new(
io::ErrorKind::Other,
"if_indextoname is not supported on this platform",
))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 9fc8065

Please sign in to comment.