Skip to content

Commit 77c57a6

Browse files
Merge pull request #1794 from rust-osdev/followup
uefi: remove inconsistent println!
2 parents 338f37d + 6149921 commit 77c57a6

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

uefi-test-runner/src/proto/network/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn test() {
9696

9797
info!("Bring up interface (ip4 config2 protocol)");
9898
let mut ip4 = Ip4Config2::new(*h).expect("open ip4 config2 protocol");
99-
ip4.ifup(true).expect("acquire ipv4 address");
99+
ip4.ifup().expect("acquire ipv4 address");
100100

101101
// hard to find web sites which still allow plain http these days ...
102102
info!("Testing HTTP");

uefi/src/proto/network/ip4config2.rs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ use alloc::vec::Vec;
99
use core::ffi::c_void;
1010
use core::net::Ipv4Addr;
1111
use core::time::Duration;
12-
12+
use log::{debug, trace};
1313
use uefi::boot::ScopedProtocol;
1414
use uefi::prelude::*;
1515
use uefi::proto::unsafe_protocol;
16-
use uefi::{print, println};
1716
use uefi_raw::protocol::network::ip4_config2::{
1817
Ip4Config2DataType, Ip4Config2InterfaceInfo, Ip4Config2Policy, Ip4Config2Protocol,
1918
};
@@ -102,39 +101,33 @@ impl Ip4Config2 {
102101
})
103102
}
104103

105-
/// Bring up network interface. Does nothing in case the network
106-
/// is already set up. Otherwise turns on DHCP and waits until an
107-
/// IPv4 address has been assigned. Reports progress on the
108-
/// console if verbose is set to true. Returns TIMEOUT error in
109-
/// case DHCP configuration does not finish within 30 seconds.
110-
pub fn ifup(&mut self, verbose: bool) -> uefi::Result<()> {
104+
/// Bring up network interface.
105+
///
106+
/// Does nothing in case the network is already set up. Otherwise turns on
107+
/// DHCP and waits until an IPv4 address has been assigned.
108+
///
109+
/// Returns TIMEOUT error in case DHCP configuration does not finish within
110+
/// 30 seconds.
111+
pub fn ifup(&mut self) -> uefi::Result<()> {
112+
const TIMEOUT_SECS: u64 = 30;
113+
111114
let no_address = Ipv4Addr::from_bits(0);
112115

113116
let info = self.get_interface_info()?;
114117
if info.station_addr != no_address.into() {
115-
if verbose {
116-
print!("Network is already up: ");
117-
println!("addr v4: {}", info.station_addr);
118-
}
118+
debug!("Network is already up: addr v4: {}", info.station_addr);
119119
return Ok(());
120120
}
121121

122-
if verbose {
123-
print!("DHCP ");
124-
}
122+
debug!("DHCP ");
125123
self.set_policy(Ip4Config2Policy::DHCP)?;
126124

127-
for _ in 0..30 {
128-
if verbose {
129-
print!(".");
130-
}
125+
for _ in 0..TIMEOUT_SECS {
131126
boot::stall(Duration::from_secs(1));
127+
trace!(".\r");
132128
let info = self.get_interface_info()?;
133129
if info.station_addr != no_address.into() {
134-
if verbose {
135-
print!(" OK: ");
136-
println!("addr v4: {}", info.station_addr);
137-
}
130+
debug!("OK: addr v4: {}", info.station_addr);
138131
return Ok(());
139132
}
140133
}

0 commit comments

Comments
 (0)