Skip to content

Commit

Permalink
fix warnings; rm dbg statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Jul 1, 2019
1 parent d825fe9 commit 6afc2e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
25 changes: 5 additions & 20 deletions lib/emscripten/src/env/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn _getaddrinfo(
});

let hints = hints_ptr.deref(memory).map(|hints_memory| {
let hints_guest = dbg!(hints_memory.get());
let hints_guest = hints_memory.get();
unsafe {
let mut hints_native: addrinfo = std::mem::uninitialized();
hints_native.ai_flags = hints_guest.ai_flags;
Expand Down Expand Up @@ -231,7 +231,7 @@ pub fn _getaddrinfo(
&mut out_ptr as *mut *mut addrinfo,
)
};
if dbg!(result) != 0 {
if result != 0 {
return result;
}

Expand All @@ -245,15 +245,13 @@ pub fn _getaddrinfo(
let current_guest_node_ptr: WasmPtr<EmAddrInfo> =
call_malloc_with_cast(ctx, std::mem::size_of::<EmAddrInfo>() as _);
if head_of_list.is_none() {
dbg!("Setting head of list");
head_of_list = Some(current_guest_node_ptr);
}

// connect list
if let Some(prev_guest) = previous_guest_node {
let mut pg = prev_guest.deref_mut(ctx.memory(0)).unwrap().get_mut();
pg.ai_next = current_guest_node_ptr;
dbg!("list connected");
}

// update values
Expand All @@ -274,15 +272,13 @@ pub fn _getaddrinfo(
guest_sockaddr_ptr
};

dbg!("Socketaddr allocated");

// allocate canon name on guest and copy data over
let guest_canonname_ptr = {
let str_ptr = (*current_host_node).ai_canonname;
if !str_ptr.is_null() {
let canonname_cstr = dbg!(std::ffi::CStr::from_ptr(str_ptr));
let canonname_cstr = std::ffi::CStr::from_ptr(str_ptr);
let canonname_bytes = canonname_cstr.to_bytes_with_nul();
let str_size = dbg!(canonname_bytes.len());
let str_size = canonname_bytes.len();
let guest_canonname: WasmPtr<c_char, Array> =
call_malloc_with_cast(ctx, str_size as _);

Expand All @@ -299,13 +295,10 @@ pub fn _getaddrinfo(
}
};

dbg!("canonname allocated");

let mut current_guest_node = current_guest_node_ptr
.deref_mut(ctx.memory(0))
.unwrap()
.get_mut();
// TODO order these
current_guest_node.ai_flags = (*current_host_node).ai_flags;
current_guest_node.ai_family = (*current_host_node).ai_family;
current_guest_node.ai_socktype = (*current_host_node).ai_socktype;
Expand All @@ -315,23 +308,15 @@ pub fn _getaddrinfo(
current_guest_node.ai_canonname = guest_canonname_ptr;
current_guest_node.ai_next = WasmPtr::new(0);

dbg!("Guest node updated");

previous_guest_node = Some(current_guest_node_ptr);
current_host_node = (*current_host_node).ai_next;
dbg!("End of loop bookkeeping finished");
}

dbg!("freeing memory");
// this frees all connected nodes on the linked list
freeaddrinfo(out_ptr);
head_of_list.unwrap_or(WasmPtr::new(0))
};

res_val_ptr
.deref(ctx.memory(0))
.unwrap()
.set(dbg!(head_of_list));
res_val_ptr.deref(ctx.memory(0)).unwrap().set(head_of_list);

0
}
10 changes: 5 additions & 5 deletions lib/emscripten/src/env/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ pub fn _gai_strerror(_ctx: &mut Ctx, _ecode: i32) -> i32 {
}

pub fn _getaddrinfo(
ctx: &mut Ctx,
node_ptr: WasmPtr<c_char>,
service_str_ptr: WasmPtr<c_char>,
hints_ptr: WasmPtr<EmAddrInfo>,
res_val_ptr: WasmPtr<WasmPtr<EmAddrInfo>>,
_ctx: &mut Ctx,
_node_ptr: WasmPtr<c_char>,
_service_str_ptr: WasmPtr<c_char>,
_hints_ptr: WasmPtr<EmAddrInfo>,
_res_val_ptr: WasmPtr<WasmPtr<EmAddrInfo>>,
) -> i32 {
debug!("emscripten::_getaddrinfo -- stub");
-1
Expand Down
8 changes: 0 additions & 8 deletions lib/emscripten/src/syscalls/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,6 @@ pub fn ___syscall102(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
let address_len: u32 = socket_varargs.get(ctx);
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as _;
let address = emscripten_memory_pointer!(ctx.memory(0), address) as *mut sockaddr;
dbg!(address);
unsafe {
dbg!(*(address as *mut u8));
dbg!(*(address as *mut u8).add(1));
for i in 0..14 {
dbg!(*(address as *mut u8).add(1 + i));
}
}
let address_len_addr =
emscripten_memory_pointer!(ctx.memory(0), address_len) as *mut socklen_t;
unsafe {
Expand Down

0 comments on commit 6afc2e4

Please sign in to comment.