From acbfec0cb51db8c621e6cf1241b910a0d799b572 Mon Sep 17 00:00:00 2001 From: Andrei Medar Date: Thu, 13 Aug 2020 14:59:30 +0000 Subject: [PATCH] cleaned up code --- oss-internship-2020/sapi_lodepng/README.md | 2 +- oss-internship-2020/sapi_lodepng/main_sandboxed.cc | 7 ++++--- oss-internship-2020/sapi_lodepng/main_unit_test.cc | 3 +-- oss-internship-2020/sapi_lodepng/sandbox.h | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/oss-internship-2020/sapi_lodepng/README.md b/oss-internship-2020/sapi_lodepng/README.md index 94542d2..20be2d0 100644 --- a/oss-internship-2020/sapi_lodepng/README.md +++ b/oss-internship-2020/sapi_lodepng/README.md @@ -10,5 +10,5 @@ TODO - clear redundant includes - check if security policy can be stricter - ~~use addDirectoryAt instead of addDirectory~~ -- modify tests assertions +- ~~modify tests assertions~~ diff --git a/oss-internship-2020/sapi_lodepng/main_sandboxed.cc b/oss-internship-2020/sapi_lodepng/main_sandboxed.cc index 169c964..66428da 100644 --- a/oss-internship-2020/sapi_lodepng/main_sandboxed.cc +++ b/oss-internship-2020/sapi_lodepng/main_sandboxed.cc @@ -47,7 +47,8 @@ void generate_one_step(SapiLodepngSandbox &sandbox, LodepngApi &api) { } // encode the image - sapi::v::Array sapi_image(image.data(), img_len(width, height)); + sapi::v::Array sapi_image(image.data(), + img_len(width, height)); sapi::v::UInt sapi_width(width), sapi_height(height); std::string filename = "/output/out_generated1.png"; sapi::v::ConstCStr sapi_filename(filename.c_str()); @@ -116,7 +117,8 @@ void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api) { } // encode the image into memory first - sapi::v::Array sapi_image(image.data(), img_len(width, height)); + sapi::v::Array sapi_image(image.data(), + img_len(width, height)); sapi::v::UInt sapi_width(width), sapi_height(height); std::string filename = "/output/out_generated2.png"; sapi::v::ConstCStr sapi_filename(filename.c_str()); @@ -135,7 +137,6 @@ void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api) { // the new array (pointed to by sapi_png_ptr) is allocated // inside the sandboxed process so we need to transfer it to this // process - sapi::v::RemotePtr sapi_remote_out_ptr(sapi_png_ptr.GetValue()); sapi::v::Array sapi_png_array(sapi_pngsize.GetValue()); diff --git a/oss-internship-2020/sapi_lodepng/main_unit_test.cc b/oss-internship-2020/sapi_lodepng/main_unit_test.cc index 0b046e4..3f4240d 100644 --- a/oss-internship-2020/sapi_lodepng/main_unit_test.cc +++ b/oss-internship-2020/sapi_lodepng/main_unit_test.cc @@ -75,9 +75,9 @@ TEST(generate_image, encode_decode_compare_one_step) { sapi_height.GetValue())); ASSERT_THAT(result, Eq(0)); + // after the image has been encoded, decode it to check that the // pixel values are the same - sapi::v::UInt sapi_width2, sapi_height2; sapi::v::IntBase sapi_image_ptr(0); @@ -161,7 +161,6 @@ TEST(generate_image, encode_decode_compare_two_steps) { // the new array (pointed to by sapi_png_ptr) is allocated // inside the sandboxed process so we need to transfer it to this // process - sapi::v::RemotePtr sapi_remote_out_ptr(sapi_png_ptr.GetValue()); sapi::v::Array sapi_png_array(sapi_pngsize.GetValue()); diff --git a/oss-internship-2020/sapi_lodepng/sandbox.h b/oss-internship-2020/sapi_lodepng/sandbox.h index 033dae9..bdbb0a2 100644 --- a/oss-internship-2020/sapi_lodepng/sandbox.h +++ b/oss-internship-2020/sapi_lodepng/sandbox.h @@ -28,7 +28,6 @@ class SapiLodepngSandbox : public LodepngSandbox { std::unique_ptr ModifyPolicy( sandbox2::PolicyBuilder *) override { return sandbox2::PolicyBuilder() - .AllowStaticStartup() .AllowRead() .AllowWrite() .AllowOpen()