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 c4b22bd commit 9272662
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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
7 changes: 6 additions & 1 deletion src/syscalls/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,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 +293,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 9272662

Please sign in to comment.