Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Jan 16, 2025
1 parent 2606322 commit daefbc3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ where
let mut current_addresses = addresses.as_ptr() as *const IP_ADAPTER_ADDRESSES_LH;
while !current_addresses.is_null() {
unsafe {
callback(*current_addresses)?;
if let Err(e) = callback(*current_addresses) {
log::debug!("Callback returned an error '{}', stopping iteration", e);
break;
}
current_addresses = (*current_addresses).Next;
}
}
Expand Down Expand Up @@ -357,7 +360,10 @@ where
let interfaces = unsafe { std::slice::from_raw_parts(first_adapter, adapter_count as usize) };

for interface in interfaces {
callback(*interface)?;
if let Err(e) = callback(*interface) {
log::debug!("Callback returned an error '{}', stopping iteration", e);
break;
}
}
Ok(())
}
Expand Down Expand Up @@ -569,8 +575,8 @@ where
let ifaces = from_raw_parts::<MIB_IPINTERFACE_ROW>(&(*if_table).Table[0], (*if_table).NumEntries as usize);
for item in ifaces {
if let Err(e) = callback(item) {
FreeMibTable(if_table as _);
return Err(e);
log::debug!("Callback returned an error '{}', stopping iteration", e);
break;
}
}
FreeMibTable(if_table as _);
Expand Down

0 comments on commit daefbc3

Please sign in to comment.