From 15a5bb445c3f599a110bfda0756baf18247ec05a Mon Sep 17 00:00:00 2001 From: diogo464 Date: Sat, 11 Oct 2025 11:40:17 +0100 Subject: fixed clippy warnings --- src/main.rs | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index c179ac0..819d656 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,10 +14,10 @@ use ipnet::Ipv4Net; use crate::dhcp::{DhcpOption, DhcpPacket}; -const BOOT_FILE_X64_BIOS: &'static str = "netboot.xyz.kpxe"; -const BOOT_FILE_X64_EFI: &'static str = "netboot.xyz.efi"; -const BOOT_FILE_A64_EFI: &'static str = "netboot.xyz-arm64.efi"; -const MENU_FILE: &'static str = "menu.ipxe"; +const BOOT_FILE_X64_BIOS: &str = "netboot.xyz.kpxe"; +const BOOT_FILE_X64_EFI: &str = "netboot.xyz.efi"; +const BOOT_FILE_A64_EFI: &str = "netboot.xyz-arm64.efi"; +const MENU_FILE: &str = "menu.ipxe"; #[derive(Debug, Parser)] struct Cli { @@ -235,14 +235,13 @@ fn handle_packet_4011(context: &Context, buf: &[u8], socket: &UdpSocket, sender_ let mut client_class = None; for option in &packet.options { - if let DhcpOption::VendorClassIdentifier(vendor_class) = option { - if let Ok(dhcp::PxeClassIdentifier::Client(class)) = + if let DhcpOption::VendorClassIdentifier(vendor_class) = option + && let Ok(dhcp::PxeClassIdentifier::Client(class)) = dhcp::PxeClassIdentifier::try_from(vendor_class.as_slice()) { println!("{class}"); client_class = Some(class); } - } } let client_class = match client_class { Some(class) => class, @@ -303,22 +302,19 @@ fn list_network_interfaces() -> Result> { .to_string_lossy() .into_owned(); - match addr_family as i32 { - libc::AF_INET => { - let addr = ifa.ifa_addr as *const libc::sockaddr_in; - let mask = ifa.ifa_netmask as *const libc::sockaddr_in; - - let addr = Ipv4Addr::from((*addr).sin_addr.s_addr.to_ne_bytes()); - let mask = Ipv4Addr::from((*mask).sin_addr.s_addr.to_ne_bytes()); - let network = Ipv4Net::with_netmask(addr, mask).unwrap().trunc(); - - interfaces.push(InterfaceAddr { - interface: name, - address: addr, - network, - }); - } - _ => {} + if addr_family as i32 == libc::AF_INET { + let addr = ifa.ifa_addr as *const libc::sockaddr_in; + let mask = ifa.ifa_netmask as *const libc::sockaddr_in; + + let addr = Ipv4Addr::from((*addr).sin_addr.s_addr.to_ne_bytes()); + let mask = Ipv4Addr::from((*mask).sin_addr.s_addr.to_ne_bytes()); + let network = Ipv4Net::with_netmask(addr, mask).unwrap().trunc(); + + interfaces.push(InterfaceAddr { + interface: name, + address: addr, + network, + }); } } -- cgit