From 61499215416a68354f4a7c8b66c29377a252b8cb Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 21 Oct 2025 07:59:40 +0200 Subject: [PATCH] uefi: remove inconsistent println ! --- uefi-test-runner/src/proto/network/http.rs | 2 +- uefi/src/proto/network/ip4config2.rs | 39 +++++++++------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/uefi-test-runner/src/proto/network/http.rs b/uefi-test-runner/src/proto/network/http.rs index 5f7f1ddf9..109fd7532 100644 --- a/uefi-test-runner/src/proto/network/http.rs +++ b/uefi-test-runner/src/proto/network/http.rs @@ -96,7 +96,7 @@ pub fn test() { info!("Bring up interface (ip4 config2 protocol)"); let mut ip4 = Ip4Config2::new(*h).expect("open ip4 config2 protocol"); - ip4.ifup(true).expect("acquire ipv4 address"); + ip4.ifup().expect("acquire ipv4 address"); // hard to find web sites which still allow plain http these days ... info!("Testing HTTP"); diff --git a/uefi/src/proto/network/ip4config2.rs b/uefi/src/proto/network/ip4config2.rs index 6328b76b1..291cf288b 100644 --- a/uefi/src/proto/network/ip4config2.rs +++ b/uefi/src/proto/network/ip4config2.rs @@ -9,11 +9,10 @@ use alloc::vec::Vec; use core::ffi::c_void; use core::net::Ipv4Addr; use core::time::Duration; - +use log::{debug, trace}; use uefi::boot::ScopedProtocol; use uefi::prelude::*; use uefi::proto::unsafe_protocol; -use uefi::{print, println}; use uefi_raw::protocol::network::ip4_config2::{ Ip4Config2DataType, Ip4Config2InterfaceInfo, Ip4Config2Policy, Ip4Config2Protocol, }; @@ -102,39 +101,33 @@ impl Ip4Config2 { }) } - /// Bring up network interface. Does nothing in case the network - /// is already set up. Otherwise turns on DHCP and waits until an - /// IPv4 address has been assigned. Reports progress on the - /// console if verbose is set to true. Returns TIMEOUT error in - /// case DHCP configuration does not finish within 30 seconds. - pub fn ifup(&mut self, verbose: bool) -> uefi::Result<()> { + /// Bring up network interface. + /// + /// Does nothing in case the network is already set up. Otherwise turns on + /// DHCP and waits until an IPv4 address has been assigned. + /// + /// Returns TIMEOUT error in case DHCP configuration does not finish within + /// 30 seconds. + pub fn ifup(&mut self) -> uefi::Result<()> { + const TIMEOUT_SECS: u64 = 30; + let no_address = Ipv4Addr::from_bits(0); let info = self.get_interface_info()?; if info.station_addr != no_address.into() { - if verbose { - print!("Network is already up: "); - println!("addr v4: {}", info.station_addr); - } + debug!("Network is already up: addr v4: {}", info.station_addr); return Ok(()); } - if verbose { - print!("DHCP "); - } + debug!("DHCP "); self.set_policy(Ip4Config2Policy::DHCP)?; - for _ in 0..30 { - if verbose { - print!("."); - } + for _ in 0..TIMEOUT_SECS { boot::stall(Duration::from_secs(1)); + trace!(".\r"); let info = self.get_interface_info()?; if info.station_addr != no_address.into() { - if verbose { - print!(" OK: "); - println!("addr v4: {}", info.station_addr); - } + debug!("OK: addr v4: {}", info.station_addr); return Ok(()); } }