Skip to content

Commit

Permalink
fix ret value
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryang00 committed Oct 16, 2023
1 parent 7fa267b commit f9d29c0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/wasm-micro-runtime
4 changes: 2 additions & 2 deletions src/wamr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ int WAMRInstance::invoke_fopen(std::string &path, uint32 option) {
argv[0] = buffer_for_wasm; // pass the buffer_ address for WASM space
argv[1] = option; // the size of buffer_
strncpy(buffer_, path.c_str(), path.size()); // use native address for accessing in runtime
auto res = wasm_runtime_call_wasm(exec_env, func, 2, argv);
wasm_runtime_call_wasm(exec_env, func, 2, argv);
wasm_runtime_module_free(module_inst, buffer_for_wasm);
return res;
return ((int)argv[0]);
}
return -1;
};
Expand Down
2 changes: 1 addition & 1 deletion src/wamr_wasi_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void WAMRWASIContext::restore_impl(WASIContext *env) {
LOGV(INFO) << "fd: " << fd << " path: " << std::get<0>(res) << " flags: " << std::get<1>(res)
<< " offset: " << std::get<2>(res);
r = wamr->invoke_fopen(std::get<0>(res), std::get<1>(res));
if (fd != 0 && fd != 1 && fd != 2)
if (r != fd)
wamr->invoke_frenumber(r, fd);
wamr->invoke_fseek(fd, std::get<2>(res));
}
Expand Down
2 changes: 1 addition & 1 deletion test/read-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ int main() {
fclose(file1);
fclose(file2);
fclose(file3);
__wasi_fd_renumber(1,1);
__wasi_fd_renumber(3,10);
}

0 comments on commit f9d29c0

Please sign in to comment.