Skip to content

Commit 241b7b8

Browse files
committed
uefi/src/proto/network/ip4config2.rs: misc
1 parent 43c29f0 commit 241b7b8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

uefi/src/proto/network/ip4config2.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
//! IP4 Config2 Protocol.
66
7-
extern crate alloc;
87
use alloc::vec;
98
use alloc::vec::Vec;
109
use core::ffi::c_void;
@@ -27,10 +26,10 @@ pub struct Ip4Config2(pub Ip4Config2Protocol);
2726

2827
impl Ip4Config2 {
2928
/// Open IP4 Config2 protocol for the given NIC handle.
30-
pub fn new(nic_handle: Handle) -> uefi::Result<ScopedProtocol<Ip4Config2>> {
29+
pub fn new(nic_handle: Handle) -> uefi::Result<ScopedProtocol<Self>> {
3130
let protocol;
3231
unsafe {
33-
protocol = boot::open_protocol::<Ip4Config2>(
32+
protocol = boot::open_protocol::<Self>(
3433
boot::OpenProtocolParams {
3534
handle: nic_handle,
3635
agent: boot::image_handle(),
@@ -45,7 +44,7 @@ impl Ip4Config2 {
4544
/// Set configuration data. It is recommended to type-specific set_* helpers instead of calling this directly.
4645
pub fn set_data(&mut self, data_type: Ip4Config2DataType, data: &mut [u8]) -> uefi::Result<()> {
4746
let status = unsafe {
48-
let data_ptr = data.as_mut_ptr() as *mut c_void;
47+
let data_ptr = data.as_mut_ptr().cast::<c_void>();
4948
(self.0.set_data)(&mut self.0, data_type, data.len(), data_ptr)
5049
};
5150
match status {
@@ -70,7 +69,7 @@ impl Ip4Config2 {
7069
// call #2: get data
7170
let mut data = vec![0; data_size];
7271
let status = unsafe {
73-
let data_ptr = data.as_mut_ptr() as *mut c_void;
72+
let data_ptr = data.as_mut_ptr().cast::<c_void>();
7473
(self.0.get_data)(&mut self.0, data_type, &mut data_size, data_ptr)
7574
};
7675
match status {
@@ -89,7 +88,7 @@ impl Ip4Config2 {
8988
pub fn get_interface_info(&mut self) -> uefi::Result<Ip4Config2InterfaceInfo> {
9089
let data = self.get_data(Ip4Config2DataType::INTERFACE_INFO)?;
9190
let info: &Ip4Config2InterfaceInfo =
92-
unsafe { &*(data.as_ptr() as *const Ip4Config2InterfaceInfo) };
91+
unsafe { &*(data.as_ptr().cast::<Ip4Config2InterfaceInfo>()) };
9392
Ok(Ip4Config2InterfaceInfo {
9493
name: info.name,
9594
if_type: info.if_type,
@@ -124,7 +123,7 @@ impl Ip4Config2 {
124123
if info.station_addr != no_address {
125124
if verbose {
126125
print!("Network is already up: ");
127-
Ip4Config2::print_info(&info);
126+
Self::print_info(&info);
128127
}
129128
return Ok(());
130129
}
@@ -143,7 +142,7 @@ impl Ip4Config2 {
143142
if info.station_addr != no_address {
144143
if verbose {
145144
print!(" OK: ");
146-
Ip4Config2::print_info(&info);
145+
Self::print_info(&info);
147146
}
148147
return Ok(());
149148
}

0 commit comments

Comments
 (0)