Skip to content

Commit dc2f252

Browse files
committed
address review comments
Signed-off-by: Jorge Prendes <[email protected]>
1 parent 0a10482 commit dc2f252

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

src/hyperlight_host/examples/func_ctx/main.rs

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,28 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
use hyperlight_host::sandbox::{MultiUseSandbox, UninitializedSandbox};
18-
use hyperlight_host::{GuestBinary, Result};
17+
use hyperlight_host::GuestBinary;
18+
use hyperlight_host::sandbox::UninitializedSandbox;
1919
use hyperlight_testing::simple_guest_as_string;
2020

2121
fn main() {
2222
// create a new `MultiUseSandbox` configured to run the `simpleguest.exe`
2323
// test guest binary
24-
let mut sbox1: MultiUseSandbox = {
25-
let path = simple_guest_as_string().unwrap();
26-
let u_sbox = UninitializedSandbox::new(GuestBinary::FilePath(path), None).unwrap();
27-
u_sbox.evolve()
28-
}
29-
.unwrap();
30-
31-
// create a new call context from the sandbox, then do some calls with it.
32-
do_calls(&mut sbox1).unwrap();
33-
34-
// create a new call context from the returned sandbox, then do some calls
35-
// with that one
36-
do_calls(&mut sbox1).unwrap();
37-
}
38-
39-
/// Given a `MultiUseGuestCallContext` derived from an existing
40-
/// `MultiUseSandbox` configured to run the `simpleguest.exe` test guest
41-
/// binary, do several calls against that binary, print their results, then
42-
/// call `ctx.finish()` and return the resulting `MultiUseSandbox`. Return an `Err`
43-
/// if anything failed.
44-
fn do_calls(sbox: &mut MultiUseSandbox) -> Result<()> {
45-
let res: String = sbox.call_guest_function_by_name("Echo", "hello".to_string())?;
24+
let path = simple_guest_as_string().unwrap();
25+
let mut sbox = UninitializedSandbox::new(GuestBinary::FilePath(path), None)
26+
.unwrap()
27+
.evolve()
28+
.unwrap();
29+
30+
// Do several calls against a sandbox running the `simpleguest.exe` binary,
31+
// and print their results
32+
let res: String = sbox
33+
.call_guest_function_by_name("Echo", "hello".to_string())
34+
.unwrap();
4635
println!("got Echo res: {res}");
4736

48-
let res: i32 = sbox.call_guest_function_by_name("CallMalloc", 200_i32)?;
37+
let res: i32 = sbox
38+
.call_guest_function_by_name("CallMalloc", 200_i32)
39+
.unwrap();
4940
println!("got CallMalloc res: {res}");
50-
51-
Ok(())
5241
}

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ where
263263
SharedMemorySnapshot::new(&mut self.shared_mem, self.mapped_rgns)
264264
}
265265

266-
/// This function restores a memory snapshot the given snapshot.
266+
/// This function restores a memory snapshot from a given snapshot.
267267
///
268268
/// Returns the number of memory regions mapped into the sandbox
269269
/// that need to be unmapped in order for the restore to be

0 commit comments

Comments
 (0)