Skip to content

Commit

Permalink
Merge pull request #1782 from OffchainLabs/fix-clippy-drop-lint
Browse files Browse the repository at this point in the history
Fix clippy lint about useless drop
  • Loading branch information
PlasmaPower authored Jul 24, 2023
2 parents ea6cbab + 6a00aa1 commit af87ba2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions arbitrator/jit/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ pub fn wasm_write(mut env: WasmEnvMut, sp: u32) {
}

pub fn nanotime1(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time);
}

pub fn walltime(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time / 1_000_000_000);
sp.write_u32(1, (env.go_state.time % 1_000_000_000) as u32);
}

pub fn walltime1(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time / 1_000_000_000);
sp.write_u64(1, env.go_state.time % 1_000_000_000);
Expand Down
5 changes: 4 additions & 1 deletion arbitrator/wasm-libraries/go-stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ pub unsafe extern "C" fn wavm__go_after_run() {
while let Some(info) = state.times.pop() {
while state.pending_ids.contains(&info.id) {
TIME = std::cmp::max(TIME, info.time);
drop(state);
// Important: the current reference to state shouldn't be used after this resume call,
// as it might during the resume call the reference might be invalidated.
// That's why immediately after this resume call, we replace the reference
// with a new reference to TIMEOUT_STATE.
wavm_guest_call__resume();
state = TIMEOUT_STATE.get_or_insert_with(Default::default);
}
Expand Down

0 comments on commit af87ba2

Please sign in to comment.