Skip to content

Commit

Permalink
revise error handling and add some kernel warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed May 22, 2024
1 parent a9a2f96 commit 950212d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/executor/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ async fn network_run() {

#[cfg(feature = "dns")]
pub(crate) async fn get_query_result(query: QueryHandle) -> Result<Vec<IpAddress>, IoError> {
use core::future::Future;

future::poll_fn(|cx| {
let mut guard = NIC.lock();
let nic = guard.as_nic_mut().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions src/syscalls/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use alloc::sync::Arc;
use core::ffi::{c_char, c_void};
use core::mem::size_of;
use core::ops::DerefMut;

#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))]
use smoltcp::wire::{IpAddress, IpEndpoint, IpListenEndpoint};

Expand Down Expand Up @@ -258,6 +257,7 @@ pub unsafe extern "C" fn sys_getaddrbyname(
_inaddr: *mut u8,
_len: usize,
) -> i32 {
warn!("Please enable the feature 'dns' to determine the network ip by name.");
-ENOSYS
}

Expand Down Expand Up @@ -292,7 +292,11 @@ pub unsafe extern "C" fn sys_getaddrbyname(
};

let name = unsafe { core::ffi::CStr::from_ptr(name) };
let name = name.to_str().expect("Bad encoding").to_owned();
let name = if let Ok(name) = name.to_str() {
name.to_owned()
} else {
return -EINVAL;
};

let query = {
let mut guard = NIC.lock();
Expand Down

0 comments on commit 950212d

Please sign in to comment.