From 75bbd0e1c139ed461d6d9af6f561c98d8ee50879 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Fri, 22 Jan 2021 06:01:05 -0800 Subject: [PATCH] Internal change Only externally visible changes should be a few changed includes as well as some formatting changes. PiperOrigin-RevId: 353226662 Change-Id: Iebf5be13774efcbd94c5d5a17b9b27e47275b229 --- oss-internship-2020/curl/examples/example1.cc | 15 ++- oss-internship-2020/curl/examples/example2.cc | 19 +-- oss-internship-2020/curl/examples/example3.cc | 38 +++--- oss-internship-2020/curl/examples/example4.cc | 17 +-- oss-internship-2020/curl/examples/example5.cc | 5 +- oss-internship-2020/curl/tests/tests.cc | 8 +- oss-internship-2020/gdal/raster.cc | 9 +- .../gdal/raster_to_gtiff/gtiff_converter.cc | 9 +- .../jsonnet/examples/jsonnet_base_example.cc | 8 +- .../examples/jsonnet_base_transaction.cc | 8 +- .../examples/jsonnet_formatter_example.cc | 8 +- .../jsonnet_multiple_files_example.cc | 8 +- .../examples/jsonnet_yaml_stream_example.cc | 8 +- .../jsonnet/tests/jsonnet_tests_utils.cc | 31 +++-- .../libarchive/examples/sapi_minitar.cc | 38 +++--- .../libpng/examples/example1.cc | 13 +- .../libpng/examples/example2.cc | 27 ++-- .../libuv/examples/idle-basic.cc | 6 +- oss-internship-2020/libuv/examples/uvcat.cc | 7 +- .../libuv/tests/test_callback.cc | 9 +- oss-internship-2020/libuv/tests/test_error.cc | 2 +- oss-internship-2020/libuv/tests/test_loop.cc | 2 +- .../lodepng/examples/main_unit_test.cc | 8 +- .../examples/stringop/main_stringop.cc | 25 ++-- sandboxed_api/examples/sum/main_sum.cc | 6 +- sandboxed_api/sandbox2/BUILD.bazel | 2 +- sandboxed_api/sandbox2/buffer_test.cc | 4 +- sandboxed_api/sandbox2/comms.cc | 1 - sandboxed_api/sandbox2/comms.h | 2 +- .../sandbox2/examples/custom_fork/BUILD.bazel | 2 - .../network_proxy/networkproxy_bin.cc | 2 +- sandboxed_api/sandbox2/ipc_test.cc | 33 ++--- sandboxed_api/sandbox2/limits_test.cc | 55 ++++---- sandboxed_api/sandbox2/mounts.cc | 9 +- sandboxed_api/sandbox2/mounts_test.cc | 17 +-- sandboxed_api/sandbox2/namespace_test.cc | 126 ++++++++++-------- .../sandbox2/network_proxy/client.cc | 2 +- .../sandbox2/network_proxy/filtering.cc | 2 +- sandboxed_api/sandbox2/policybuilder_test.cc | 30 ++--- sandboxed_api/sandbox2/sandbox2_test.cc | 72 +++++----- sandboxed_api/sandbox2/sanitizer_test.cc | 11 +- sandboxed_api/sandbox2/stack_trace_test.cc | 12 +- .../sandbox2/util/maps_parser_test.cc | 2 +- sandboxed_api/sandbox2/util/minielf.cc | 8 +- sandboxed_api/sandbox2/util/minielf_test.cc | 3 +- .../tools/clang_generator/emitter.cc | 11 +- .../tools/clang_generator/generator_tool.cc | 2 +- sandboxed_api/transaction.cc | 4 +- sandboxed_api/transaction.h | 1 - sandboxed_api/var_abstract.cc | 2 +- sandboxed_api/var_array.h | 2 +- sandboxed_api/var_int.cc | 1 + sandboxed_api/var_lenval.cc | 5 +- sandboxed_api/var_proto.h | 2 +- 54 files changed, 412 insertions(+), 347 deletions(-) diff --git a/oss-internship-2020/curl/examples/example1.cc b/oss-internship-2020/curl/examples/example1.cc index 588ba2b..b10f2ea 100644 --- a/oss-internship-2020/curl/examples/example1.cc +++ b/oss-internship-2020/curl/examples/example1.cc @@ -39,22 +39,25 @@ absl::Status Example1() { // Specify URL to get sapi::v::ConstCStr url("http://example.com"); - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, - url.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, url.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Set the library to follow a redirection - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_long( - &curl, curl::CURLOPT_FOLLOWLOCATION, 1l)); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_long(&curl, curl::CURLOPT_FOLLOWLOCATION, 1l)); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_long failed: " + curl_code); } // Disable authentication of peer certificate - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_long( - &curl, curl::CURLOPT_SSL_VERIFYPEER, 0l)); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_long(&curl, curl::CURLOPT_SSL_VERIFYPEER, 0l)); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_long failed: " + curl_code); } diff --git a/oss-internship-2020/curl/examples/example2.cc b/oss-internship-2020/curl/examples/example2.cc index 1117a03..92abb58 100644 --- a/oss-internship-2020/curl/examples/example2.cc +++ b/oss-internship-2020/curl/examples/example2.cc @@ -46,16 +46,17 @@ absl::Status Example2() { // Specify URL to get sapi::v::ConstCStr url("http://example.com"); - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, - url.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, url.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Set WriteMemoryCallback as the write function - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_WRITEFUNCTION, - &write_to_memory)); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_WRITEFUNCTION, + &write_to_memory)); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } @@ -63,8 +64,8 @@ absl::Status Example2() { // Pass 'chunk' struct to the callback function sapi::v::LenVal chunk(0); SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_WRITEDATA, - chunk.PtrBoth())); + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_WRITEDATA, + chunk.PtrBoth())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } @@ -72,8 +73,8 @@ absl::Status Example2() { // Set a user agent sapi::v::ConstCStr user_agent("libcurl-agent/1.0"); SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_USERAGENT, - user_agent.PtrBefore())); + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_USERAGENT, + user_agent.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } diff --git a/oss-internship-2020/curl/examples/example3.cc b/oss-internship-2020/curl/examples/example3.cc index 98c5095..ff390c8 100644 --- a/oss-internship-2020/curl/examples/example3.cc +++ b/oss-internship-2020/curl/examples/example3.cc @@ -78,26 +78,27 @@ absl::Status Example3(std::string ssl_certificate, std::string ssl_key, // Specify URL to get (using HTTPS) sapi::v::ConstCStr url("https://example.com"); - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, - url.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, url.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Set the SSL certificate type to "PEM" sapi::v::ConstCStr ssl_cert_type("PEM"); - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_SSLCERTTYPE, - ssl_cert_type.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_SSLCERTTYPE, + ssl_cert_type.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Set the certificate for client authentication sapi::v::ConstCStr sapi_ssl_certificate(ssl_certificate.c_str()); - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_SSLCERT, - sapi_ssl_certificate.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_SSLCERT, + sapi_ssl_certificate.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } @@ -105,33 +106,34 @@ absl::Status Example3(std::string ssl_certificate, std::string ssl_key, // Set the private key for client authentication sapi::v::ConstCStr sapi_ssl_key(ssl_key.c_str()); SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_SSLKEY, - sapi_ssl_key.PtrBefore())); + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_SSLKEY, + sapi_ssl_key.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Set the password used to protect the private key sapi::v::ConstCStr sapi_ssl_key_password(ssl_key_password.c_str()); - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_KEYPASSWD, - sapi_ssl_key_password.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_KEYPASSWD, + sapi_ssl_key_password.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Set the file with the certificates vaildating the server sapi::v::ConstCStr sapi_ca_certificates(ca_certificates.c_str()); - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_CAINFO, - sapi_ca_certificates.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_CAINFO, + sapi_ca_certificates.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } // Verify the authenticity of the server - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_long( - &curl, curl::CURLOPT_SSL_VERIFYPEER, 1L)); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_long(&curl, curl::CURLOPT_SSL_VERIFYPEER, 1L)); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_long failed: " + curl_code); } diff --git a/oss-internship-2020/curl/examples/example4.cc b/oss-internship-2020/curl/examples/example4.cc index 88b8f5e..09aae02 100644 --- a/oss-internship-2020/curl/examples/example4.cc +++ b/oss-internship-2020/curl/examples/example4.cc @@ -50,9 +50,9 @@ absl::Status Example4() { // Specify URL to get sapi::v::ConstCStr url("http://example.com"); - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_easy_setopt_ptr(&http_handle, curl::CURLOPT_URL, - url.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_easy_setopt_ptr(&http_handle, curl::CURLOPT_URL, + url.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } @@ -68,7 +68,7 @@ absl::Status Example4() { // Add http_handle to the multi stack SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_multi_add_handle(&multi_handle, &http_handle)); + api.curl_multi_add_handle(&multi_handle, &http_handle)); if (curl_code != 0) { return absl::UnavailableError("curl_multi_add_handle failed: " + curl_code); } @@ -77,8 +77,9 @@ absl::Status Example4() { sapi::v::Int numfds(0); // Perform the request - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_multi_perform( - &multi_handle, still_running.PtrBoth())); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_multi_perform(&multi_handle, still_running.PtrBoth())); if (curl_code != 0) { return absl::UnavailableError("curl_mutli_perform failed: " + curl_code); } @@ -97,8 +98,8 @@ absl::Status Example4() { } // Remove http_handle from the multi stack - SAPI_ASSIGN_OR_RETURN(curl_code, - api.curl_multi_remove_handle(&multi_handle, &http_handle)); + SAPI_ASSIGN_OR_RETURN( + curl_code, api.curl_multi_remove_handle(&multi_handle, &http_handle)); if (curl_code != 0) { return absl::UnavailableError("curl_multi_remove_handle failed: " + curl_code); diff --git a/oss-internship-2020/curl/examples/example5.cc b/oss-internship-2020/curl/examples/example5.cc index b1f94f3..c83caa3 100644 --- a/oss-internship-2020/curl/examples/example5.cc +++ b/oss-internship-2020/curl/examples/example5.cc @@ -36,8 +36,9 @@ absl::Status pull_one_url(const std::string& url, curl::CurlApi& api) { // Specify URL to get sapi::v::ConstCStr sapi_url(url.c_str()); - SAPI_ASSIGN_OR_RETURN(curl_code, api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, - sapi_url.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + curl_code, + api.curl_easy_setopt_ptr(&curl, curl::CURLOPT_URL, sapi_url.PtrBefore())); if (curl_code != 0) { return absl::UnavailableError("curl_easy_setopt_ptr failed: " + curl_code); } diff --git a/oss-internship-2020/curl/tests/tests.cc b/oss-internship-2020/curl/tests/tests.cc index 90771e4..214b9c0 100644 --- a/oss-internship-2020/curl/tests/tests.cc +++ b/oss-internship-2020/curl/tests/tests.cc @@ -46,8 +46,8 @@ TEST_F(CurlTest, EffectiveUrl) { // Store effective URL in a string SAPI_ASSERT_OK_AND_ASSIGN(std::string effective_url, - sandbox_->GetCString(sapi::v::RemotePtr( - effective_url_ptr.GetPointedVar()))); + sandbox_->GetCString(sapi::v::RemotePtr( + effective_url_ptr.GetPointedVar()))); // Compare effective URL with original URL ASSERT_EQ(effective_url, kUrl); @@ -99,8 +99,8 @@ TEST_F(CurlTest, ContentType) { // Store content type in a string SAPI_ASSERT_OK_AND_ASSIGN(std::string content_type, - sandbox_->GetCString(sapi::v::RemotePtr( - content_type_ptr.GetPointedVar()))); + sandbox_->GetCString(sapi::v::RemotePtr( + content_type_ptr.GetPointedVar()))); // Compare content type with "text/plain" ASSERT_EQ(content_type, "text/plain"); diff --git a/oss-internship-2020/gdal/raster.cc b/oss-internship-2020/gdal/raster.cc index d8d0464..3020b94 100644 --- a/oss-internship-2020/gdal/raster.cc +++ b/oss-internship-2020/gdal/raster.cc @@ -101,8 +101,9 @@ absl::Status GdalMain(std::string filename) { // analyzing the returning object. // Same for GDALReturnsIO from below. CPLErr err; - SAPI_ASSIGN_OR_RETURN(err, api.GDALGetGeoTransform( - &ptr_dataset, adf_geo_transform_array.PtrBoth())); + SAPI_ASSIGN_OR_RETURN( + err, + api.GDALGetGeoTransform(&ptr_dataset, adf_geo_transform_array.PtrBoth())); // If GDALGetGeoTransform generates an error. if (err != CE_None) { @@ -127,8 +128,8 @@ absl::Status GdalMain(std::string filename) { } sapi::v::RemotePtr ptr_band(band.value()); - SAPI_RETURN_IF_ERROR(api.GDALGetBlockSize(&ptr_band, nBlockXSizeArray.PtrBoth(), - nBlockYSizeArray.PtrBoth())); + SAPI_RETURN_IF_ERROR(api.GDALGetBlockSize( + &ptr_band, nBlockXSizeArray.PtrBoth(), nBlockYSizeArray.PtrBoth())); LOG(INFO) << "Block = " << n_blockX_size[0] << " x " << n_blockY_size[0] << std::endl; diff --git a/oss-internship-2020/gdal/raster_to_gtiff/gtiff_converter.cc b/oss-internship-2020/gdal/raster_to_gtiff/gtiff_converter.cc index e8afaf8..d27b6d8 100644 --- a/oss-internship-2020/gdal/raster_to_gtiff/gtiff_converter.cc +++ b/oss-internship-2020/gdal/raster_to_gtiff/gtiff_converter.cc @@ -44,7 +44,7 @@ absl::Status RasterToGTiffProcessor::Main() { sapi::v::CStr driver_name_ptr(kDriverName); SAPI_ASSIGN_OR_RETURN(absl::StatusOr driver, - api.GDALGetDriverByName(driver_name_ptr.PtrBefore())); + api.GDALGetDriverByName(driver_name_ptr.PtrBefore())); TRANSACTION_FAIL_IF_NOT(driver.value() != nullptr, "Error getting GTiff driver"); @@ -69,7 +69,7 @@ absl::Status RasterToGTiffProcessor::Main() { int current_band = 1; for (auto& band_data : data_.bands) { SAPI_ASSIGN_OR_RETURN(absl::StatusOr band, - api.GDALGetRasterBand(&dataset_ptr, current_band)); + api.GDALGetRasterBand(&dataset_ptr, current_band)); TRANSACTION_FAIL_IF_NOT(band.value() != nullptr, "Error getting band from dataset"); sapi::v::RemotePtr band_ptr(band.value()); @@ -95,8 +95,9 @@ absl::Status RasterToGTiffProcessor::Main() { "Error setting color interpretation"); if (band_data.no_data_value.has_value()) { - SAPI_ASSIGN_OR_RETURN(result, api.GDALSetRasterNoDataValue( - &band_ptr, band_data.no_data_value.value())); + SAPI_ASSIGN_OR_RETURN(result, + api.GDALSetRasterNoDataValue( + &band_ptr, band_data.no_data_value.value())); TRANSACTION_FAIL_IF_NOT(result.value() == CPLErr::CE_None, "Error setting no data value for the band"); diff --git a/oss-internship-2020/jsonnet/examples/jsonnet_base_example.cc b/oss-internship-2020/jsonnet/examples/jsonnet_base_example.cc index f76ecb2..5a32cdd 100644 --- a/oss-internship-2020/jsonnet/examples/jsonnet_base_example.cc +++ b/oss-internship-2020/jsonnet/examples/jsonnet_base_example.cc @@ -37,14 +37,14 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file))); sapi::v::ConstCStr in_file_var(in_file_in_sandboxee.c_str()); SAPI_ASSIGN_OR_RETURN(char* input, - api.c_read_input(false, in_file_var.PtrBefore())); + api.c_read_input(false, in_file_var.PtrBefore())); // Process jsonnet data. sapi::v::RemotePtr input_pointer(input); sapi::v::Int error; SAPI_ASSIGN_OR_RETURN(char* output, api.c_jsonnet_evaluate_snippet( - &vm_pointer, in_file_var.PtrBefore(), - &input_pointer, error.PtrAfter())); + &vm_pointer, in_file_var.PtrBefore(), + &input_pointer, error.PtrAfter())); CHECK(!error.GetValue()) << "Jsonnet code evaluation failed: " << error.GetValue() << "\n" << "Make sure all files used by your jsonnet file " @@ -62,7 +62,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { // Clean up. SAPI_ASSIGN_OR_RETURN(char* result, - api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); + api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); SAPI_RETURN_IF_ERROR(api.c_jsonnet_destroy(&vm_pointer)); SAPI_RETURN_IF_ERROR(api.c_free_input(&input_pointer)); diff --git a/oss-internship-2020/jsonnet/examples/jsonnet_base_transaction.cc b/oss-internship-2020/jsonnet/examples/jsonnet_base_transaction.cc index d4f00fd..177f2c3 100644 --- a/oss-internship-2020/jsonnet/examples/jsonnet_base_transaction.cc +++ b/oss-internship-2020/jsonnet/examples/jsonnet_base_transaction.cc @@ -31,14 +31,14 @@ absl::Status JsonnetTransaction::Main() { std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file))); sapi::v::ConstCStr in_file_var(in_file_in_sandboxee.c_str()); SAPI_ASSIGN_OR_RETURN(char* input, - api.c_read_input(false, in_file_var.PtrBefore())); + api.c_read_input(false, in_file_var.PtrBefore())); // Process jsonnet data. sapi::v::RemotePtr input_pointer(input); sapi::v::Int error; SAPI_ASSIGN_OR_RETURN(char* output, api.c_jsonnet_evaluate_snippet( - &vm_pointer, in_file_var.PtrBefore(), - &input_pointer, error.PtrAfter())); + &vm_pointer, in_file_var.PtrBefore(), + &input_pointer, error.PtrAfter())); TRANSACTION_FAIL_IF_NOT(error.GetValue() == 0, "Jsonnet code evaluation failed."); @@ -53,7 +53,7 @@ absl::Status JsonnetTransaction::Main() { // Clean up. SAPI_ASSIGN_OR_RETURN(char* result, - api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); + api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); SAPI_RETURN_IF_ERROR(api.c_jsonnet_destroy(&vm_pointer)); SAPI_RETURN_IF_ERROR(api.c_free_input(&input_pointer)); diff --git a/oss-internship-2020/jsonnet/examples/jsonnet_formatter_example.cc b/oss-internship-2020/jsonnet/examples/jsonnet_formatter_example.cc index ae101d4..c9c608b 100644 --- a/oss-internship-2020/jsonnet/examples/jsonnet_formatter_example.cc +++ b/oss-internship-2020/jsonnet/examples/jsonnet_formatter_example.cc @@ -71,14 +71,14 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file))); sapi::v::ConstCStr in_file_var(in_file_in_sandboxee.c_str()); SAPI_ASSIGN_OR_RETURN(char* input, - api.c_read_input(false, in_file_var.PtrBefore())); + api.c_read_input(false, in_file_var.PtrBefore())); // Process jsonnet data. sapi::v::RemotePtr input_pointer(input); sapi::v::Int error; SAPI_ASSIGN_OR_RETURN(char* output, api.c_jsonnet_fmt_snippet( - &vm_pointer, in_file_var.PtrBefore(), - &input_pointer, error.PtrAfter())); + &vm_pointer, in_file_var.PtrBefore(), + &input_pointer, error.PtrAfter())); CHECK(!error.GetValue()) << "Jsonnet code evaluation failed: " << error.GetValue() << "\n"; @@ -95,7 +95,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { // Clean up. SAPI_ASSIGN_OR_RETURN(char* result, - api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); + api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); SAPI_RETURN_IF_ERROR(api.c_jsonnet_destroy(&vm_pointer)); SAPI_RETURN_IF_ERROR(api.c_free_input(&input_pointer)); diff --git a/oss-internship-2020/jsonnet/examples/jsonnet_multiple_files_example.cc b/oss-internship-2020/jsonnet/examples/jsonnet_multiple_files_example.cc index 984ec72..74f644e 100644 --- a/oss-internship-2020/jsonnet/examples/jsonnet_multiple_files_example.cc +++ b/oss-internship-2020/jsonnet/examples/jsonnet_multiple_files_example.cc @@ -74,14 +74,14 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file))); sapi::v::ConstCStr in_file_var(in_file_in_sandboxee.c_str()); SAPI_ASSIGN_OR_RETURN(char* input, - api.c_read_input(false, in_file_var.PtrBefore())); + api.c_read_input(false, in_file_var.PtrBefore())); // Process jsonnet data. sapi::v::RemotePtr input_pointer(input); sapi::v::Int error; SAPI_ASSIGN_OR_RETURN(char* output, api.c_jsonnet_evaluate_snippet_multi( - &vm_pointer, in_file_var.PtrBefore(), - &input_pointer, error.PtrAfter())); + &vm_pointer, in_file_var.PtrBefore(), + &input_pointer, error.PtrAfter())); CHECK(!error.GetValue()) << "Jsonnet code evaluation failed: " << error.GetValue() << "\n" << "Make sure all files used by your jsonnet file " @@ -99,7 +99,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { // Clean up. SAPI_ASSIGN_OR_RETURN(char* result, - api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); + api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); SAPI_RETURN_IF_ERROR(api.c_jsonnet_destroy(&vm_pointer)); SAPI_RETURN_IF_ERROR(api.c_free_input(&input_pointer)); diff --git a/oss-internship-2020/jsonnet/examples/jsonnet_yaml_stream_example.cc b/oss-internship-2020/jsonnet/examples/jsonnet_yaml_stream_example.cc index 2942724..9e5cad6 100644 --- a/oss-internship-2020/jsonnet/examples/jsonnet_yaml_stream_example.cc +++ b/oss-internship-2020/jsonnet/examples/jsonnet_yaml_stream_example.cc @@ -37,14 +37,14 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file))); sapi::v::ConstCStr in_file_var(in_file_in_sandboxee.c_str()); SAPI_ASSIGN_OR_RETURN(char* input, - api.c_read_input(false, in_file_var.PtrBefore())); + api.c_read_input(false, in_file_var.PtrBefore())); // Process jsonnet data. sapi::v::RemotePtr input_pointer(input); sapi::v::Int error; SAPI_ASSIGN_OR_RETURN(char* output, api.c_jsonnet_evaluate_snippet_stream( - &vm_pointer, in_file_var.PtrBefore(), - &input_pointer, error.PtrAfter())); + &vm_pointer, in_file_var.PtrBefore(), + &input_pointer, error.PtrAfter())); CHECK(!error.GetValue()) << "Jsonnet code evaluation failed: " << error.GetValue() << "\n" << "Make sure all files used by your jsonnet file are in the same " @@ -62,7 +62,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) { // Clean up. SAPI_ASSIGN_OR_RETURN(char* result, - api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); + api.c_jsonnet_realloc(&vm_pointer, &output_pointer, 0)); SAPI_RETURN_IF_ERROR(api.c_jsonnet_destroy(&vm_pointer)); SAPI_RETURN_IF_ERROR(api.c_free_input(&input_pointer)); diff --git a/oss-internship-2020/jsonnet/tests/jsonnet_tests_utils.cc b/oss-internship-2020/jsonnet/tests/jsonnet_tests_utils.cc index 5e24dc6..7b588ef 100644 --- a/oss-internship-2020/jsonnet/tests/jsonnet_tests_utils.cc +++ b/oss-internship-2020/jsonnet/tests/jsonnet_tests_utils.cc @@ -46,8 +46,8 @@ void JsonnetTestHelper::TestSetUp() { // Cleans up after a test. void JsonnetTestHelper::TestTearDown() { if (jsonnet_vm_was_used_) { - SAPI_ASSERT_OK_AND_ASSIGN(char* result, - api_->c_jsonnet_realloc(vm_.get(), output_.get(), 0)); + SAPI_ASSERT_OK_AND_ASSIGN( + char* result, api_->c_jsonnet_realloc(vm_.get(), output_.get(), 0)); } ASSERT_THAT(api_->c_jsonnet_destroy(vm_.get()), sapi::IsOk()); if (input_was_read_) { @@ -63,7 +63,7 @@ void JsonnetTestHelper::ReadInput(const char* filename) { sapi::v::ConstCStr in_file_var(input_filename_in_sandboxee_.c_str()); SAPI_ASSERT_OK_AND_ASSIGN(char* input_ptr, - api_->c_read_input(0, in_file_var.PtrBefore())); + api_->c_read_input(0, in_file_var.PtrBefore())); input_ = absl::make_unique(input_ptr); input_was_read_ = true; @@ -78,23 +78,26 @@ void JsonnetTestHelper::Evaluate_jsonnet_code(Evaluation type, switch (type) { case kBase: { - SAPI_ASSERT_OK_AND_ASSIGN(output_ptr, api_->c_jsonnet_evaluate_snippet( - vm_.get(), in_file_var.PtrBefore(), + SAPI_ASSERT_OK_AND_ASSIGN( + output_ptr, + api_->c_jsonnet_evaluate_snippet(vm_.get(), in_file_var.PtrBefore(), input_.get(), error.PtrAfter())); break; } case kMultipleFiles: { - SAPI_ASSERT_OK_AND_ASSIGN(output_ptr, api_->c_jsonnet_evaluate_snippet_multi( - vm_.get(), in_file_var.PtrBefore(), - input_.get(), error.PtrAfter())); + SAPI_ASSERT_OK_AND_ASSIGN( + output_ptr, api_->c_jsonnet_evaluate_snippet_multi( + vm_.get(), in_file_var.PtrBefore(), input_.get(), + error.PtrAfter())); break; } case kYamlStream: { - SAPI_ASSERT_OK_AND_ASSIGN(output_ptr, api_->c_jsonnet_evaluate_snippet_stream( - vm_.get(), in_file_var.PtrBefore(), - input_.get(), error.PtrAfter())); + SAPI_ASSERT_OK_AND_ASSIGN( + output_ptr, api_->c_jsonnet_evaluate_snippet_stream( + vm_.get(), in_file_var.PtrBefore(), input_.get(), + error.PtrAfter())); break; } } @@ -130,9 +133,9 @@ void JsonnetTestHelper::WriteOutput(const char* filename_or_directory, case kMultipleFiles: { std::string out_file_in_sandboxee(std::string("/output/")); sapi::v::ConstCStr out_file_var(out_file_in_sandboxee.c_str()); - SAPI_ASSERT_OK_AND_ASSIGN(success, - api_->c_write_multi_output_files( - output_.get(), out_file_var.PtrBefore(), false)); + SAPI_ASSERT_OK_AND_ASSIGN( + success, api_->c_write_multi_output_files( + output_.get(), out_file_var.PtrBefore(), false)); break; } diff --git a/oss-internship-2020/libarchive/examples/sapi_minitar.cc b/oss-internship-2020/libarchive/examples/sapi_minitar.cc index cf26dbe..accdfb7 100644 --- a/oss-internship-2020/libarchive/examples/sapi_minitar.cc +++ b/oss-internship-2020/libarchive/examples/sapi_minitar.cc @@ -106,8 +106,9 @@ absl::Status CreateArchive(const char* initial_filename, int compress, filename_ptr = nullptr; } - SAPI_ASSIGN_OR_RETURN(rc, api.archive_write_open_filename( - &a, sapi::v::ConstCStr(filename_ptr).PtrBefore())); + SAPI_ASSIGN_OR_RETURN(rc, + api.archive_write_open_filename( + &a, sapi::v::ConstCStr(filename_ptr).PtrBefore())); if (rc != ARCHIVE_OK) { return absl::FailedPreconditionError( "Unexpected result from write_open_filename call"); @@ -139,7 +140,7 @@ absl::Status CreateArchive(const char* initial_filename, int compress, sapi::v::ConstCStr(absolute_paths[file_idx].c_str()).PtrBefore())); if (rc != ARCHIVE_OK) { SAPI_ASSIGN_OR_RETURN(msg, CheckStatusAndGetString( - api.archive_error_string(&disk), sandbox)); + api.archive_error_string(&disk), sandbox)); return absl::FailedPreconditionError(msg); } @@ -160,8 +161,9 @@ absl::Status CreateArchive(const char* initial_filename, int compress, } if (rc != ARCHIVE_OK) { - SAPI_ASSIGN_OR_RETURN(msg, CheckStatusAndGetString( - api.archive_error_string(&disk), sandbox)); + SAPI_ASSIGN_OR_RETURN( + msg, + CheckStatusAndGetString(api.archive_error_string(&disk), sandbox)); return absl::FailedPreconditionError(msg); } @@ -209,8 +211,9 @@ absl::Status CreateArchive(const char* initial_filename, int compress, &entry, sapi::v::ConstCStr(path_name.c_str()).PtrBefore())); if (verbose) { - SAPI_ASSIGN_OR_RETURN(msg, CheckStatusAndGetString( - api.archive_entry_pathname(&entry), sandbox)); + SAPI_ASSIGN_OR_RETURN( + msg, CheckStatusAndGetString(api.archive_entry_pathname(&entry), + sandbox)); std::cout << msg << std::endl; } @@ -218,7 +221,7 @@ absl::Status CreateArchive(const char* initial_filename, int compress, if (rc < ARCHIVE_OK) { SAPI_ASSIGN_OR_RETURN(msg, CheckStatusAndGetString( - api.archive_error_string(&a), sandbox)); + api.archive_error_string(&a), sandbox)); std::cout << msg << std::endl; } if (rc == ARCHIVE_FATAL) { @@ -256,11 +259,12 @@ absl::Status CreateArchive(const char* initial_filename, int compress, sandbox.Call("read", &read_ret, &sapi_fd, buff.PtrNone(), &ssize)); while (read_ret.GetValue() > 0) { - SAPI_ASSIGN_OR_RETURN(rc, api.archive_write_data(&a, buff.PtrNone(), - read_ret.GetValue())); + SAPI_ASSIGN_OR_RETURN( + rc, + api.archive_write_data(&a, buff.PtrNone(), read_ret.GetValue())); SAPI_RETURN_IF_ERROR(sandbox.Call("read", &read_ret, &sapi_fd, - buff.PtrNone(), &ssize)); + buff.PtrNone(), &ssize)); } // sapi_fd variable goes out of scope here so both the local and the // remote file descriptors are closed. @@ -426,8 +430,9 @@ absl::Status ExtractArchive(const char* filename, int do_extract, int flags, } if (verbose || !do_extract) { - SAPI_ASSIGN_OR_RETURN(msg, CheckStatusAndGetString( - api.archive_entry_pathname(&entry), sandbox)); + SAPI_ASSIGN_OR_RETURN( + msg, + CheckStatusAndGetString(api.archive_entry_pathname(&entry), sandbox)); std::cout << msg << std::endl; } @@ -436,7 +441,7 @@ absl::Status ExtractArchive(const char* filename, int do_extract, int flags, if (rc != ARCHIVE_OK) { SAPI_ASSIGN_OR_RETURN(msg, CheckStatusAndGetString( - api.archive_error_string(&a), sandbox)); + api.archive_error_string(&a), sandbox)); std::cout << msg << std::endl; } else { SAPI_ASSIGN_OR_RETURN(rc, CopyData(&a, &ext, api, sandbox)); @@ -502,8 +507,9 @@ absl::StatusOr CopyData(sapi::v::RemotePtr* ar, sapi::v::RemotePtr* aw, sapi::v::RemotePtr buff(buff_ptr_tmp.GetValue()); - SAPI_ASSIGN_OR_RETURN(rc, api.archive_write_data_block( - aw, &buff, size.GetValue(), offset.GetValue())); + SAPI_ASSIGN_OR_RETURN( + rc, api.archive_write_data_block(aw, &buff, size.GetValue(), + offset.GetValue())); if (rc != ARCHIVE_OK) { SAPI_ASSIGN_OR_RETURN( diff --git a/oss-internship-2020/libpng/examples/example1.cc b/oss-internship-2020/libpng/examples/example1.cc index e2139d0..ac90298 100644 --- a/oss-internship-2020/libpng/examples/example1.cc +++ b/oss-internship-2020/libpng/examples/example1.cc @@ -32,8 +32,9 @@ absl::Status LibPNGMain(const std::string& infile, const std::string& outfile) { image.mutable_data()->version = PNG_IMAGE_VERSION; - SAPI_ASSIGN_OR_RETURN(int result, api.png_image_begin_read_from_file( - image.PtrBoth(), infile_var.PtrBefore())); + SAPI_ASSIGN_OR_RETURN( + int result, api.png_image_begin_read_from_file(image.PtrBoth(), + infile_var.PtrBefore())); if (!result) { return absl::InternalError( absl::StrCat("begin read error: ", image.mutable_data()->message)); @@ -45,16 +46,16 @@ absl::Status LibPNGMain(const std::string& infile, const std::string& outfile) { sapi::v::NullPtr null = sapi::v::NullPtr(); SAPI_ASSIGN_OR_RETURN(result, - api.png_image_finish_read(image.PtrBoth(), &null, - buffer.PtrBoth(), 0, &null)); + api.png_image_finish_read(image.PtrBoth(), &null, + buffer.PtrBoth(), 0, &null)); if (!result) { return absl::InternalError( absl::StrCat("finish read error: ", image.mutable_data()->message)); } SAPI_ASSIGN_OR_RETURN(result, api.png_image_write_to_file( - image.PtrBoth(), outfile_var.PtrBefore(), 0, - buffer.PtrBoth(), 0, &null)); + image.PtrBoth(), outfile_var.PtrBefore(), 0, + buffer.PtrBoth(), 0, &null)); if (!result) { return absl::InternalError( absl::StrCat("write error: ", image.mutable_data()->message)); diff --git a/oss-internship-2020/libpng/examples/example2.cc b/oss-internship-2020/libpng/examples/example2.cc index 18124ec..dabde57 100644 --- a/oss-internship-2020/libpng/examples/example2.cc +++ b/oss-internship-2020/libpng/examples/example2.cc @@ -44,7 +44,7 @@ absl::StatusOr ReadPng(LibPNGApi& api, absl::string_view infile) { absl::StatusOr status_or_file; sapi::v::ConstCStr rb_var("rb"); SAPI_ASSIGN_OR_RETURN(status_or_file, - api.png_fdopen(fd.GetRemoteFd(), rb_var.PtrBefore())); + api.png_fdopen(fd.GetRemoteFd(), rb_var.PtrBefore())); sapi::v::RemotePtr file(status_or_file.value()); if (!file.GetValue()) { @@ -52,10 +52,11 @@ absl::StatusOr ReadPng(LibPNGApi& api, absl::string_view infile) { } sapi::v::Array header(8); - SAPI_RETURN_IF_ERROR(api.png_fread(header.PtrBoth(), 1, header.GetSize(), &file)); + SAPI_RETURN_IF_ERROR( + api.png_fread(header.PtrBoth(), 1, header.GetSize(), &file)); SAPI_ASSIGN_OR_RETURN(int return_value, - api.png_sig_cmp(header.PtrBoth(), 0, header.GetSize())); + api.png_sig_cmp(header.PtrBoth(), 0, header.GetSize())); if (return_value != 0) { return absl::InternalError(absl::StrCat(infile, " is not a PNG file")); } @@ -74,7 +75,7 @@ absl::StatusOr ReadPng(LibPNGApi& api, absl::string_view infile) { absl::StatusOr status_or_png_infop; SAPI_ASSIGN_OR_RETURN(status_or_png_infop, - api.png_create_info_struct(&struct_ptr)); + api.png_create_info_struct(&struct_ptr)); sapi::v::RemotePtr info_ptr(status_or_png_infop.value()); if (!info_ptr.GetValue()) { @@ -87,24 +88,26 @@ absl::StatusOr ReadPng(LibPNGApi& api, absl::string_view infile) { SAPI_RETURN_IF_ERROR(api.png_read_info(&struct_ptr, &info_ptr)); Data data; - SAPI_ASSIGN_OR_RETURN(data.width, api.png_get_image_width(&struct_ptr, &info_ptr)); + SAPI_ASSIGN_OR_RETURN(data.width, + api.png_get_image_width(&struct_ptr, &info_ptr)); SAPI_ASSIGN_OR_RETURN(data.height, - api.png_get_image_height(&struct_ptr, &info_ptr)); + api.png_get_image_height(&struct_ptr, &info_ptr)); SAPI_ASSIGN_OR_RETURN(data.color_type, - api.png_get_color_type(&struct_ptr, &info_ptr)); + api.png_get_color_type(&struct_ptr, &info_ptr)); SAPI_ASSIGN_OR_RETURN(data.bit_depth, - api.png_get_bit_depth(&struct_ptr, &info_ptr)); + api.png_get_bit_depth(&struct_ptr, &info_ptr)); SAPI_ASSIGN_OR_RETURN(data.number_of_passes, - api.png_set_interlace_handling(&struct_ptr)); + api.png_set_interlace_handling(&struct_ptr)); SAPI_RETURN_IF_ERROR(api.png_read_update_info(&struct_ptr, &info_ptr)); SAPI_RETURN_IF_ERROR(api.png_setjmp(&struct_ptr)); - SAPI_ASSIGN_OR_RETURN(data.rowbytes, api.png_get_rowbytes(&struct_ptr, &info_ptr)); + SAPI_ASSIGN_OR_RETURN(data.rowbytes, + api.png_get_rowbytes(&struct_ptr, &info_ptr)); data.row_pointers = std::make_unique>(data.height * data.rowbytes); @@ -129,7 +132,7 @@ absl::Status WritePng(LibPNGApi& api, absl::string_view outfile, Data& data) { absl::StatusOr status_or_file; sapi::v::ConstCStr wb_var("wb"); SAPI_ASSIGN_OR_RETURN(status_or_file, - api.png_fdopen(fd.GetRemoteFd(), wb_var.PtrBefore())); + api.png_fdopen(fd.GetRemoteFd(), wb_var.PtrBefore())); sapi::v::RemotePtr file(status_or_file.value()); if (!file.GetValue()) { @@ -150,7 +153,7 @@ absl::Status WritePng(LibPNGApi& api, absl::string_view outfile, Data& data) { absl::StatusOr status_or_png_infop; SAPI_ASSIGN_OR_RETURN(status_or_png_infop, - api.png_create_info_struct(&struct_ptr)); + api.png_create_info_struct(&struct_ptr)); sapi::v::RemotePtr info_ptr(status_or_png_infop.value()); if (!info_ptr.GetValue()) { diff --git a/oss-internship-2020/libuv/examples/idle-basic.cc b/oss-internship-2020/libuv/examples/idle-basic.cc index 14a1e5b..c5abd45 100644 --- a/oss-internship-2020/libuv/examples/idle-basic.cc +++ b/oss-internship-2020/libuv/examples/idle-basic.cc @@ -46,7 +46,8 @@ absl::Status IdleBasic() { // Get remote pointer to the IdleCallback method void* function_ptr; - SAPI_RETURN_IF_ERROR(sandbox.rpc_channel()->Symbol("IdleCallback", &function_ptr)); + SAPI_RETURN_IF_ERROR( + sandbox.rpc_channel()->Symbol("IdleCallback", &function_ptr)); sapi::v::RemotePtr idle_callback(function_ptr); // Allocate memory for the uv_idle_t object @@ -69,7 +70,8 @@ absl::Status IdleBasic() { } // Start idler - SAPI_ASSIGN_OR_RETURN(return_code, api.sapi_uv_idle_start(&idler, &idle_callback)); + SAPI_ASSIGN_OR_RETURN(return_code, + api.sapi_uv_idle_start(&idler, &idle_callback)); if (return_code != 0) { return absl::UnavailableError("sapi_uv_idle_start returned error " + return_code); diff --git a/oss-internship-2020/libuv/examples/uvcat.cc b/oss-internship-2020/libuv/examples/uvcat.cc index 6a73835..6c32dd2 100644 --- a/oss-internship-2020/libuv/examples/uvcat.cc +++ b/oss-internship-2020/libuv/examples/uvcat.cc @@ -61,7 +61,8 @@ absl::Status UVCat(std::string filearg) { // Get remote pointer to the open_req variable void* open_req_voidptr; - SAPI_RETURN_IF_ERROR(sandbox.rpc_channel()->Symbol("open_req", &open_req_voidptr)); + SAPI_RETURN_IF_ERROR( + sandbox.rpc_channel()->Symbol("open_req", &open_req_voidptr)); sapi::v::RemotePtr open_req(open_req_voidptr); // Get default loop @@ -72,8 +73,8 @@ absl::Status UVCat(std::string filearg) { // Open file using the OnOpen callback (which will also read and print it) sapi::v::ConstCStr filename(filearg.c_str()); - SAPI_ASSIGN_OR_RETURN(return_code, - api.sapi_uv_fs_open(&loop, &open_req, filename.PtrBefore(), + SAPI_ASSIGN_OR_RETURN( + return_code, api.sapi_uv_fs_open(&loop, &open_req, filename.PtrBefore(), O_RDONLY, 0, &on_open)); if (return_code != 0) { return absl::UnavailableError("uv_fs_open returned error " + return_code); diff --git a/oss-internship-2020/libuv/tests/test_callback.cc b/oss-internship-2020/libuv/tests/test_callback.cc index 004e923..addda42 100644 --- a/oss-internship-2020/libuv/tests/test_callback.cc +++ b/oss-internship-2020/libuv/tests/test_callback.cc @@ -48,7 +48,8 @@ class UVTestCallback : public ::testing::Test { // Check sapi_uv_timer_init void UVTimerInit(sapi::v::Ptr* loop, sapi::v::Ptr* timer) { - SAPI_ASSERT_OK_AND_ASSIGN(int error_code, api_->sapi_uv_timer_init(loop, timer)); + SAPI_ASSERT_OK_AND_ASSIGN(int error_code, + api_->sapi_uv_timer_init(loop, timer)); ASSERT_EQ(error_code, 0); } @@ -63,15 +64,15 @@ class UVTestCallback : public ::testing::Test { sapi::v::RemotePtr timer_cb(timer_cb_voidptr); // Set the timer's callback, timeout and repeat - SAPI_ASSERT_OK_AND_ASSIGN(int error_code, - api_->sapi_uv_timer_start(timer, &timer_cb, 0, 0)); + SAPI_ASSERT_OK_AND_ASSIGN( + int error_code, api_->sapi_uv_timer_start(timer, &timer_cb, 0, 0)); ASSERT_EQ(error_code, 0); } // Check sapi_uv_run void UVRun(sapi::v::Ptr* loop) { SAPI_ASSERT_OK_AND_ASSIGN(int error_code, - api_->sapi_uv_run(loop, UV_RUN_DEFAULT)); + api_->sapi_uv_run(loop, UV_RUN_DEFAULT)); ASSERT_EQ(error_code, 0); } diff --git a/oss-internship-2020/libuv/tests/test_error.cc b/oss-internship-2020/libuv/tests/test_error.cc index a2e228d..a4a0a44 100644 --- a/oss-internship-2020/libuv/tests/test_error.cc +++ b/oss-internship-2020/libuv/tests/test_error.cc @@ -62,7 +62,7 @@ class UVTestError : public ::testing::Test { void UVTranslateSysError(int error) { // Call sapi_uv_translate_sys_error and get error code SAPI_ASSERT_OK_AND_ASSIGN(int error_code, - api_->sapi_uv_translate_sys_error(error)); + api_->sapi_uv_translate_sys_error(error)); // Check that it is equal to expected error code ASSERT_EQ(error_code, uv_translate_sys_error(error)); diff --git a/oss-internship-2020/libuv/tests/test_loop.cc b/oss-internship-2020/libuv/tests/test_loop.cc index 6433d78..819a523 100644 --- a/oss-internship-2020/libuv/tests/test_loop.cc +++ b/oss-internship-2020/libuv/tests/test_loop.cc @@ -54,7 +54,7 @@ class UVTestLoop : public ::testing::Test { // Check sapi_uv_run void UVRun(sapi::v::Ptr* loop) { SAPI_ASSERT_OK_AND_ASSIGN(int error_code, - api_->sapi_uv_run(loop, UV_RUN_DEFAULT)); + api_->sapi_uv_run(loop, UV_RUN_DEFAULT)); ASSERT_EQ(error_code, 0); } diff --git a/oss-internship-2020/lodepng/examples/main_unit_test.cc b/oss-internship-2020/lodepng/examples/main_unit_test.cc index 99f4b88..8160a2a 100644 --- a/oss-internship-2020/lodepng/examples/main_unit_test.cc +++ b/oss-internship-2020/lodepng/examples/main_unit_test.cc @@ -84,10 +84,10 @@ TEST(LodePngTest, EncodeDecodeOneStep) { sapi::v::UInt sapi_width, sapi_height; sapi::v::IntBase sapi_image_ptr(0); - SAPI_ASSERT_OK_AND_ASSIGN(result, - api.lodepng_decode32_file( - sapi_image_ptr.PtrBoth(), sapi_width.PtrBoth(), - sapi_height.PtrBoth(), sapi_filename.PtrBefore())); + SAPI_ASSERT_OK_AND_ASSIGN( + result, api.lodepng_decode32_file( + sapi_image_ptr.PtrBoth(), sapi_width.PtrBoth(), + sapi_height.PtrBoth(), sapi_filename.PtrBefore())); ASSERT_THAT(result, Eq(0)) << "Unexpected result from decode32_file call"; diff --git a/sandboxed_api/examples/stringop/main_stringop.cc b/sandboxed_api/examples/stringop/main_stringop.cc index c7e5b2e..79b86d8 100644 --- a/sandboxed_api/examples/stringop/main_stringop.cc +++ b/sandboxed_api/examples/stringop/main_stringop.cc @@ -27,9 +27,9 @@ #include "sandboxed_api/examples/stringop/lib/stringop-sapi.sapi.h" #include "sandboxed_api/examples/stringop/lib/stringop_params.pb.h" #include "sandboxed_api/transaction.h" +#include "sandboxed_api/util/status_macros.h" #include "sandboxed_api/util/status_matchers.h" #include "sandboxed_api/vars.h" -#include "sandboxed_api/util/status_macros.h" using ::sapi::IsOk; using ::testing::Eq; @@ -48,7 +48,8 @@ TEST(StringopTest, ProtobufStringDuplication) { proto.set_input("Hello"); sapi::v::Proto pp(proto); { - SAPI_ASSIGN_OR_RETURN(int return_value, api.pb_duplicate_string(pp.PtrBoth())); + SAPI_ASSIGN_OR_RETURN(int return_value, + api.pb_duplicate_string(pp.PtrBoth())); TRANSACTION_FAIL_IF_NOT(return_value, "pb_duplicate_string() failed"); } @@ -69,7 +70,8 @@ TEST(StringopTest, ProtobufStringReversal) { stringop::StringReverse proto; proto.set_input("Hello"); sapi::v::Proto pp(proto); - SAPI_ASSERT_OK_AND_ASSIGN(int return_value, api.pb_reverse_string(pp.PtrBoth())); + SAPI_ASSERT_OK_AND_ASSIGN(int return_value, + api.pb_reverse_string(pp.PtrBoth())); EXPECT_THAT(return_value, Ne(0)) << "pb_reverse_string() failed"; SAPI_ASSERT_OK_AND_ASSIGN(auto pb_result, pp.GetMessage()); @@ -83,7 +85,8 @@ TEST(StringopTest, RawStringDuplication) { StringopApi api(&sandbox); sapi::v::LenVal param("0123456789", 10); - SAPI_ASSERT_OK_AND_ASSIGN(int return_value, api.duplicate_string(param.PtrBoth())); + SAPI_ASSERT_OK_AND_ASSIGN(int return_value, + api.duplicate_string(param.PtrBoth())); EXPECT_THAT(return_value, Eq(1)) << "duplicate_string() failed"; absl::string_view data(reinterpret_cast(param.GetData()), @@ -100,7 +103,8 @@ TEST(StringopTest, RawStringReversal) { sapi::v::LenVal param("0123456789", 10); { - SAPI_ASSERT_OK_AND_ASSIGN(int return_value, api.reverse_string(param.PtrBoth())); + SAPI_ASSERT_OK_AND_ASSIGN(int return_value, + api.reverse_string(param.PtrBoth())); EXPECT_THAT(return_value, Eq(1)) << "reverse_string() returned incorrect value"; absl::string_view data(reinterpret_cast(param.GetData()), @@ -120,7 +124,8 @@ TEST(StringopTest, RawStringReversal) { EXPECT_THAT(data, SizeIs(16)) << "Resize did not behave correctly"; EXPECT_THAT(std::string(data), StrEq("9876543210ABCDEF")); - SAPI_ASSERT_OK_AND_ASSIGN(int return_value, api.reverse_string(param.PtrBoth())); + SAPI_ASSERT_OK_AND_ASSIGN(int return_value, + api.reverse_string(param.PtrBoth())); EXPECT_THAT(return_value, Eq(1)) << "reverse_string() returned incorrect value"; data = absl::string_view(reinterpret_cast(param.GetData()), @@ -135,7 +140,7 @@ TEST(StringopTest, RawStringLength) { StringopApi api(&sandbox); SAPI_ASSERT_OK_AND_ASSIGN(void* target_mem_ptr, api.get_raw_c_string()); SAPI_ASSERT_OK_AND_ASSIGN(size_t len, - sandbox.rpc_channel()->Strlen(target_mem_ptr)); + sandbox.rpc_channel()->Strlen(target_mem_ptr)); EXPECT_THAT(len, Eq(10)); } @@ -145,11 +150,11 @@ TEST(StringopTest, RawStringReading) { StringopApi api(&sandbox); SAPI_ASSERT_OK_AND_ASSIGN(void* target_mem_ptr, api.get_raw_c_string()); SAPI_ASSERT_OK_AND_ASSIGN(size_t len, - sandbox.rpc_channel()->Strlen(target_mem_ptr)); + sandbox.rpc_channel()->Strlen(target_mem_ptr)); EXPECT_THAT(len, Eq(10)); - SAPI_ASSERT_OK_AND_ASSIGN(std::string data, - sandbox.GetCString(sapi::v::RemotePtr(target_mem_ptr))); + SAPI_ASSERT_OK_AND_ASSIGN( + std::string data, sandbox.GetCString(sapi::v::RemotePtr(target_mem_ptr))); EXPECT_THAT(data, StrEq("Ten chars.")); } diff --git a/sandboxed_api/examples/sum/main_sum.cc b/sandboxed_api/examples/sum/main_sum.cc index 51e233f..9cd2ceb 100644 --- a/sandboxed_api/examples/sum/main_sum.cc +++ b/sandboxed_api/examples/sum/main_sum.cc @@ -157,13 +157,15 @@ absl::Status SumTransaction::Main() { char buffer[1024] = {0}; sapi::v::Array buf(buffer, sizeof(buffer)); sapi::v::UInt size(128); - SAPI_RETURN_IF_ERROR(sandbox()->Call("read", &ret, &fd2, buf.PtrBoth(), &size)); + SAPI_RETURN_IF_ERROR( + sandbox()->Call("read", &ret, &fd2, buf.PtrBoth(), &size)); LOG(INFO) << "Read from /proc/self/comm = [" << buffer << "]"; // Close test. SAPI_RETURN_IF_ERROR(fd2.CloseRemoteFd(sandbox()->rpc_channel())); memset(buffer, 0, sizeof(buffer)); - SAPI_RETURN_IF_ERROR(sandbox()->Call("read", &ret, &fd2, buf.PtrBoth(), &size)); + SAPI_RETURN_IF_ERROR( + sandbox()->Call("read", &ret, &fd2, buf.PtrBoth(), &size)); LOG(INFO) << "Read from closed /proc/self/comm = [" << buffer << "]"; // Pass fd as function arg example. diff --git a/sandboxed_api/sandbox2/BUILD.bazel b/sandboxed_api/sandbox2/BUILD.bazel index 813f173..2314069 100644 --- a/sandboxed_api/sandbox2/BUILD.bazel +++ b/sandboxed_api/sandbox2/BUILD.bazel @@ -601,7 +601,7 @@ cc_library( ":util", "//sandboxed_api/util:raw_logging", "//sandboxed_api/util:status", - "//sandboxed_api/util:status_proto", + "//sandboxed_api/util:status_cc_proto", "//sandboxed_api/util:strerror", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/memory", diff --git a/sandboxed_api/sandbox2/buffer_test.cc b/sandboxed_api/sandbox2/buffer_test.cc index 189c154..fa9f067 100644 --- a/sandboxed_api/sandbox2/buffer_test.cc +++ b/sandboxed_api/sandbox2/buffer_test.cc @@ -111,7 +111,7 @@ TEST(BufferTest, TestWithSandboxeeMapFd) { auto policy = BufferTestcasePolicy(); SAPI_ASSERT_OK_AND_ASSIGN(auto buffer, - Buffer::CreateWithSize(1ULL << 20 /* 1MiB */)); + Buffer::CreateWithSize(1ULL << 20 /* 1MiB */)); // buffer() uses the internal fd to mmap the buffer. uint8_t* buf = buffer->data(); // Test that we can write data to the sandboxee. @@ -149,7 +149,7 @@ TEST(BufferTest, TestWithSandboxeeSendRecv) { ASSERT_THAT(s2.RunAsync(), IsTrue()); SAPI_ASSERT_OK_AND_ASSIGN(auto buffer, - Buffer::CreateWithSize(1ULL << 20 /* 1MiB */)); + Buffer::CreateWithSize(1ULL << 20 /* 1MiB */)); uint8_t* buf = buffer->data(); // Test that we can write data to the sandboxee. buf[0] = 'A'; diff --git a/sandboxed_api/sandbox2/comms.cc b/sandboxed_api/sandbox2/comms.cc index 0db3584..17ec60e 100644 --- a/sandboxed_api/sandbox2/comms.cc +++ b/sandboxed_api/sandbox2/comms.cc @@ -44,7 +44,6 @@ #include "sandboxed_api/util/raw_logging.h" #include "sandboxed_api/util/status.h" #include "sandboxed_api/util/strerror.h" -#include "sandboxed_api/util/status_macros.h" #ifdef MEMORY_SANITIZER #include "base/dynamic_annotations.h" diff --git a/sandboxed_api/sandbox2/comms.h b/sandboxed_api/sandbox2/comms.h index fca8c53..12e0385 100644 --- a/sandboxed_api/sandbox2/comms.h +++ b/sandboxed_api/sandbox2/comms.h @@ -38,7 +38,7 @@ namespace proto2 { class Message; -} +} // namespace proto2 namespace sandbox2 { diff --git a/sandboxed_api/sandbox2/examples/custom_fork/BUILD.bazel b/sandboxed_api/sandbox2/examples/custom_fork/BUILD.bazel index 8ef3202..d96ab08 100644 --- a/sandboxed_api/sandbox2/examples/custom_fork/BUILD.bazel +++ b/sandboxed_api/sandbox2/examples/custom_fork/BUILD.bazel @@ -31,9 +31,7 @@ cc_binary( "//sandboxed_api/sandbox2:comms", "//sandboxed_api/sandbox2:forkserver", "//sandboxed_api/util:flags", - "//sandboxed_api/util:raw_logging", "//sandboxed_api/util:runfiles", - "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/memory", ], ) diff --git a/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_bin.cc b/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_bin.cc index 9f10975..84b1064 100644 --- a/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_bin.cc +++ b/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_bin.cc @@ -20,8 +20,8 @@ #include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/sandbox2/network_proxy/client.h" #include "sandboxed_api/util/fileops.h" -#include "sandboxed_api/util/strerror.h" #include "sandboxed_api/util/status_macros.h" +#include "sandboxed_api/util/strerror.h" ABSL_FLAG(bool, connect_with_handler, true, "Connect using automatic mode."); diff --git a/sandboxed_api/sandbox2/ipc_test.cc b/sandboxed_api/sandbox2/ipc_test.cc index 124995e..56049f6 100644 --- a/sandboxed_api/sandbox2/ipc_test.cc +++ b/sandboxed_api/sandbox2/ipc_test.cc @@ -45,11 +45,12 @@ TEST(IPCTest, MapFDByNamePreExecve) { auto executor = absl::make_unique(path, args); Comms comms(executor->ipc()->ReceiveFd(kPreferredIpcFd, "ipc_test")); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 s2(std::move(executor), std::move(policy)); s2.RunAsync(); @@ -76,11 +77,12 @@ TEST(IPCTest, MapFDByNamePostExecve) { executor->set_enable_sandbox_before_exec(false); Comms comms(executor->ipc()->ReceiveFd(kPreferredIpcFd, "ipc_test")); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 s2(std::move(executor), std::move(policy)); s2.RunAsync(); @@ -103,11 +105,12 @@ TEST(IPCTest, NoMappedFDsPreExecve) { std::vector args = {path, "3"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); diff --git a/sandboxed_api/sandbox2/limits_test.cc b/sandboxed_api/sandbox2/limits_test.cc index 2f9c08d..72d636b 100644 --- a/sandboxed_api/sandbox2/limits_test.cc +++ b/sandboxed_api/sandbox2/limits_test.cc @@ -44,11 +44,12 @@ TEST(LimitsTest, RLimitASMmapUnderLimit) { auto executor = absl::make_unique(path, args); executor->limits()->set_rlimit_as(100ULL << 20); // 100 MiB - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, sandbox2::PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + sandbox2::PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); @@ -62,11 +63,12 @@ TEST(LimitsTest, RLimitASMmapAboveLimit) { auto executor = absl::make_unique(path, args); executor->limits()->set_rlimit_as(100ULL << 20); // 100 MiB - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, sandbox2::PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + sandbox2::PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); @@ -80,11 +82,12 @@ TEST(LimitsTest, RLimitASAllocaSmallUnderLimit) { auto executor = absl::make_unique(path, args); executor->limits()->set_rlimit_as(100ULL << 20); // 100 MiB - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, sandbox2::PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + sandbox2::PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); @@ -98,11 +101,12 @@ TEST(LimitsTest, RLimitASAllocaBigUnderLimit) { auto executor = absl::make_unique(path, args); executor->limits()->set_rlimit_as(100ULL << 20); // 100 MiB - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, sandbox2::PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + sandbox2::PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); @@ -116,11 +120,12 @@ TEST(LimitsTest, RLimitASAllocaBigAboveLimit) { auto executor = absl::make_unique(path, args); executor->limits()->set_rlimit_as(100ULL << 20); // 100 MiB - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, sandbox2::PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + sandbox2::PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); diff --git a/sandboxed_api/sandbox2/mounts.cc b/sandboxed_api/sandbox2/mounts.cc index 4684259..5636335 100644 --- a/sandboxed_api/sandbox2/mounts.cc +++ b/sandboxed_api/sandbox2/mounts.cc @@ -39,8 +39,8 @@ #include "sandboxed_api/util/fileops.h" #include "sandboxed_api/util/path.h" #include "sandboxed_api/util/raw_logging.h" -#include "sandboxed_api/util/strerror.h" #include "sandboxed_api/util/status_macros.h" +#include "sandboxed_api/util/strerror.h" namespace sandbox2 { namespace { @@ -306,9 +306,10 @@ void LogContainer(const std::vector& container) { absl::Status Mounts::AddMappingsForBinary(const std::string& path, absl::string_view ld_library_path) { - SAPI_ASSIGN_OR_RETURN(auto elf, ElfFile::ParseFromFile( - path, ElfFile::kGetInterpreter | - ElfFile::kLoadImportedLibraries)); + SAPI_ASSIGN_OR_RETURN( + auto elf, + ElfFile::ParseFromFile( + path, ElfFile::kGetInterpreter | ElfFile::kLoadImportedLibraries)); const std::string& interpreter = elf.interpreter(); if (interpreter.empty()) { diff --git a/sandboxed_api/sandbox2/mounts_test.cc b/sandboxed_api/sandbox2/mounts_test.cc index 4076cd9..f701a23 100644 --- a/sandboxed_api/sandbox2/mounts_test.cc +++ b/sandboxed_api/sandbox2/mounts_test.cc @@ -94,11 +94,11 @@ TEST(MountTreeTest, TestMultipleInsertionFileSymlink) { Mounts mounts; SAPI_ASSERT_OK_AND_ASSIGN(std::string path, - CreateNamedTempFileAndClose( - file::JoinPath(GetTestTempPath(), "testdir_"))); + CreateNamedTempFileAndClose( + file::JoinPath(GetTestTempPath(), "testdir_"))); SAPI_ASSERT_OK_AND_ASSIGN(std::string symlink_path, - CreateNamedTempFileAndClose( - file::JoinPath(GetTestTempPath(), "testdir_"))); + CreateNamedTempFileAndClose( + file::JoinPath(GetTestTempPath(), "testdir_"))); ASSERT_THAT(unlink(symlink_path.c_str()), Eq(0)); ASSERT_THAT(symlink(path.c_str(), symlink_path.c_str()), Eq(0)); @@ -111,11 +111,12 @@ TEST(MountTreeTest, TestMultipleInsertionFileSymlink) { TEST(MountTreeTest, TestMultipleInsertionDirSymlink) { Mounts mounts; - SAPI_ASSERT_OK_AND_ASSIGN(std::string path, CreateTempDir(file::JoinPath( - GetTestTempPath(), "testdir_"))); + SAPI_ASSERT_OK_AND_ASSIGN( + std::string path, + CreateTempDir(file::JoinPath(GetTestTempPath(), "testdir_"))); SAPI_ASSERT_OK_AND_ASSIGN(std::string symlink_path, - CreateNamedTempFileAndClose( - file::JoinPath(GetTestTempPath(), "testdir_"))); + CreateNamedTempFileAndClose( + file::JoinPath(GetTestTempPath(), "testdir_"))); ASSERT_THAT(unlink(symlink_path.c_str()), Eq(0)); ASSERT_THAT(symlink(path.c_str(), symlink_path.c_str()), Eq(0)); diff --git a/sandboxed_api/sandbox2/namespace_test.cc b/sandboxed_api/sandbox2/namespace_test.cc index 10bf693..650f148 100644 --- a/sandboxed_api/sandbox2/namespace_test.cc +++ b/sandboxed_api/sandbox2/namespace_test.cc @@ -53,11 +53,12 @@ TEST(NamespaceTest, FileNamespaceWorks) { const std::string path = GetTestSourcePath("sandbox2/testcases/namespace"); std::vector args = {path, "0", "/binary_path", "/etc/passwd"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .AddFileAt(path, "/binary_path") - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .AddFileAt(path, "/binary_path") + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -76,11 +77,12 @@ TEST(NamespaceTest, ReadOnlyIsRespected) { // First check that it is readable std::vector args = {path, "0", "/temp_file"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .AddFileAt(name, "/temp_file") - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .AddFileAt(name, "/temp_file") + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -92,11 +94,12 @@ TEST(NamespaceTest, ReadOnlyIsRespected) { // Then check that it is not writeable std::vector args = {path, "1", "/temp_file"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .AddFileAt(name, "/temp_file") - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .AddFileAt(name, "/temp_file") + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -112,10 +115,11 @@ TEST(NamespaceTest, UserNamespaceWorks) { std::vector args = {path, "2"}; { auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -127,11 +131,12 @@ TEST(NamespaceTest, UserNamespaceWorks) { // Validate that getpid() does not return 2 when outside of an pid NS. { auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -148,10 +153,11 @@ TEST(NamespaceTest, UserNamespaceIDMapWritten) { { std::vector args = {path, "3", "1000", "1000"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -166,11 +172,12 @@ TEST(NamespaceTest, UserNamespaceIDMapWritten) { const std::string gid = absl::StrCat(getgid()); std::vector args = {path, "3", uid, gid}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -186,11 +193,12 @@ TEST(NamespaceTest, RootReadOnly) { const std::string path = GetTestSourcePath("sandbox2/testcases/namespace"); std::vector args = {path, "4", "/tmp/testfile", "/testfile"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .AddTmpfs("/tmp") - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .AddTmpfs("/tmp") + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -204,11 +212,12 @@ TEST(NamespaceTest, RootWritable) { const std::string path = GetTestSourcePath("sandbox2/testcases/namespace"); std::vector args = {path, "4", "/testfile"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .SetRootWritable() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .SetRootWritable() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -233,30 +242,33 @@ class HostnameTest : public testing::Test { }; TEST_F(HostnameTest, None) { - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .TryBuild()); Try("sandbox2", std::move(policy)); EXPECT_EQ(code_, 1); } TEST_F(HostnameTest, Default) { - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .TryBuild()); Try("sandbox2", std::move(policy)); EXPECT_EQ(code_, 0); } TEST_F(HostnameTest, Configured) { - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all - .DangerDefaultAllowAll() - .SetHostname("configured") - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all + .DangerDefaultAllowAll() + .SetHostname("configured") + .TryBuild()); Try("configured", std::move(policy)); EXPECT_EQ(code_, 0); } diff --git a/sandboxed_api/sandbox2/network_proxy/client.cc b/sandboxed_api/sandbox2/network_proxy/client.cc index 14809a8..80d5ed8 100644 --- a/sandboxed_api/sandbox2/network_proxy/client.cc +++ b/sandboxed_api/sandbox2/network_proxy/client.cc @@ -28,8 +28,8 @@ #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "sandboxed_api/config.h" -#include "sandboxed_api/util/strerror.h" #include "sandboxed_api/util/status_macros.h" +#include "sandboxed_api/util/strerror.h" namespace sandbox2 { diff --git a/sandboxed_api/sandbox2/network_proxy/filtering.cc b/sandboxed_api/sandbox2/network_proxy/filtering.cc index 15987a7..4df8f3b 100644 --- a/sandboxed_api/sandbox2/network_proxy/filtering.cc +++ b/sandboxed_api/sandbox2/network_proxy/filtering.cc @@ -22,8 +22,8 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" -#include "sandboxed_api/util/strerror.h" #include "sandboxed_api/util/status_macros.h" +#include "sandboxed_api/util/strerror.h" namespace sandbox2 { diff --git a/sandboxed_api/sandbox2/policybuilder_test.cc b/sandboxed_api/sandbox2/policybuilder_test.cc index 094b6cd..6d62658 100644 --- a/sandboxed_api/sandbox2/policybuilder_test.cc +++ b/sandboxed_api/sandbox2/policybuilder_test.cc @@ -24,6 +24,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/memory/memory.h" +#include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -36,19 +37,6 @@ #include "sandboxed_api/sandbox2/util/bpf_helper.h" #include "sandboxed_api/testing.h" #include "sandboxed_api/util/status_matchers.h" -#include "absl/status/status.h" - -using ::sapi::GetTestSourcePath; -using ::testing::AllOf; -using ::testing::AnyOf; -using ::testing::Eq; -using ::testing::Gt; -using ::testing::HasSubstr; -using ::testing::Lt; -using ::testing::NotNull; -using ::testing::StartsWith; -using ::testing::StrEq; -using ::sapi::StatusIs; namespace sandbox2 { @@ -69,6 +57,18 @@ class PolicyBuilderPeer { namespace { +using ::sapi::GetTestSourcePath; +using ::testing::AllOf; +using ::testing::AnyOf; +using ::testing::Eq; +using ::testing::Gt; +using ::testing::HasSubstr; +using ::testing::Lt; +using ::testing::NotNull; +using ::testing::StartsWith; +using ::testing::StrEq; +using ::sapi::StatusIs; + class PolicyBuilderTest : public testing::Test { protected: static std::string Run(std::vector args, bool network = false); @@ -149,8 +149,8 @@ TEST_F(PolicyBuilderTest, TestValidateAbsolutePath) { for (auto const& good_path : {"/", "/a/b/c/d", "/a/b/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}) { - SAPI_ASSERT_OK_AND_ASSIGN(std::string path, - PolicyBuilderPeer::ValidateAbsolutePath(good_path)); + SAPI_ASSERT_OK_AND_ASSIGN( + std::string path, PolicyBuilderPeer::ValidateAbsolutePath(good_path)); EXPECT_THAT(path, StrEq(good_path)); } } diff --git a/sandboxed_api/sandbox2/sandbox2_test.cc b/sandboxed_api/sandbox2/sandbox2_test.cc index 2b06e95..7601be8 100644 --- a/sandboxed_api/sandbox2/sandbox2_test.cc +++ b/sandboxed_api/sandbox2/sandbox2_test.cc @@ -55,11 +55,12 @@ TEST(SandboxCoreDumpTest, AbortWithoutCoreDumpReturnsSignaled) { }; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -77,11 +78,12 @@ TEST(TsyncTest, TsyncNoMemoryChecks) { auto executor = absl::make_unique(path, args); executor->set_enable_sandbox_before_exec(false); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -104,11 +106,12 @@ TEST(ExecutorTest, ExecutorFdConstructor) { std::vector envs; auto executor = absl::make_unique(fd, args, envs); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); auto result = sandbox.Run(); @@ -124,10 +127,11 @@ TEST(RunAsyncTest, SandboxeeExternalKill) { std::vector envs; auto executor = absl::make_unique(path, args, envs); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); ASSERT_TRUE(sandbox.RunAsync()); sleep(1); @@ -146,10 +150,11 @@ TEST(RunAsyncTest, SandboxeeTimeoutWithStacktraces) { std::vector envs; auto executor = absl::make_unique(path, args, envs); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); ASSERT_TRUE(sandbox.RunAsync()); sandbox.set_walltime_limit(absl::Seconds(1)); @@ -166,11 +171,12 @@ TEST(RunAsyncTest, SandboxeeTimeoutDisabledStacktraces) { std::vector envs; auto executor = absl::make_unique(path, args, envs); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .CollectStacktracesOnTimeout(false) - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .CollectStacktracesOnTimeout(false) + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); ASSERT_TRUE(sandbox.RunAsync()); sandbox.set_walltime_limit(absl::Seconds(1)); @@ -187,11 +193,11 @@ TEST(RunAsyncTest, SandboxeeViolationDisabledStacktraces) { std::vector envs; auto executor = absl::make_unique(path, args, envs); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, - PolicyBuilder() - // Don't allow anything - Make sure that we'll crash. - .CollectStacktracesOnViolation(false) - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN( + auto policy, PolicyBuilder() + // Don't allow anything - Make sure that we'll crash. + .CollectStacktracesOnViolation(false) + .TryBuild()); Sandbox2 sandbox(std::move(executor), std::move(policy)); ASSERT_TRUE(sandbox.RunAsync()); auto result = sandbox.AwaitResult(); diff --git a/sandboxed_api/sandbox2/sanitizer_test.cc b/sandboxed_api/sandbox2/sanitizer_test.cc index 113e05a..bda1317 100644 --- a/sandboxed_api/sandbox2/sanitizer_test.cc +++ b/sandboxed_api/sandbox2/sanitizer_test.cc @@ -120,11 +120,12 @@ TEST(SanitizerTest, TestSandboxedBinary) { }; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder() - .DisableNamespaces() - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN(auto policy, + PolicyBuilder() + .DisableNamespaces() + // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .TryBuild()); Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); diff --git a/sandboxed_api/sandbox2/stack_trace_test.cc b/sandboxed_api/sandbox2/stack_trace_test.cc index 2a8e37c..b06bcb3 100644 --- a/sandboxed_api/sandbox2/stack_trace_test.cc +++ b/sandboxed_api/sandbox2/stack_trace_test.cc @@ -181,12 +181,12 @@ TEST(StackTraceTest, SymbolizationTrustedFilesOnly) { const std::string path = GetTestSourcePath("sandbox2/testcases/symbolize"); std::vector args = {path, "2"}; auto executor = absl::make_unique(path, args); - SAPI_ASSERT_OK_AND_ASSIGN(auto policy, PolicyBuilder{} - // Don't restrict the syscalls at all. - .DangerDefaultAllowAll() - .AddFile(path) - .AddLibrariesForBinary(path) - .TryBuild()); + SAPI_ASSERT_OK_AND_ASSIGN( + auto policy, PolicyBuilder{} // Don't restrict the syscalls at all. + .DangerDefaultAllowAll() + .AddFile(path) + .AddLibrariesForBinary(path) + .TryBuild()); Sandbox2 s2(std::move(executor), std::move(policy)); auto result = s2.Run(); diff --git a/sandboxed_api/sandbox2/util/maps_parser_test.cc b/sandboxed_api/sandbox2/util/maps_parser_test.cc index 0995f08..c88f14c 100644 --- a/sandboxed_api/sandbox2/util/maps_parser_test.cc +++ b/sandboxed_api/sandbox2/util/maps_parser_test.cc @@ -62,7 +62,7 @@ TEST(MapsParserTest, ParsesValidFileCorrectly) { 7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0 [stack] )ValidMapsFile"; // NOLINT SAPI_ASSERT_OK_AND_ASSIGN(std::vector entries, - ParseProcMaps(kValidMapsFile)); + ParseProcMaps(kValidMapsFile)); EXPECT_THAT(entries.size(), Eq(32)); EXPECT_THAT(entries[0].start, Eq(0x555555554000)); EXPECT_THAT(entries[1].start, Eq(0x55555575b000)); diff --git a/sandboxed_api/sandbox2/util/minielf.cc b/sandboxed_api/sandbox2/util/minielf.cc index 44717e9..426367d 100644 --- a/sandboxed_api/sandbox2/util/minielf.cc +++ b/sandboxed_api/sandbox2/util/minielf.cc @@ -27,8 +27,8 @@ #include "sandboxed_api/config.h" #include "sandboxed_api/sandbox2/util.h" #include "sandboxed_api/util/raw_logging.h" -#include "sandboxed_api/util/strerror.h" #include "sandboxed_api/util/status_macros.h" +#include "sandboxed_api/util/strerror.h" namespace host_cpu = ::sapi::host_cpu; using ::sapi::StrError; @@ -370,7 +370,8 @@ absl::Status ElfParser::ReadSymbolsFromSymtab(const ElfShdr& symtab) { absl::StrCat("invalid symtab's strtab reference: ", symtab.sh_link)); } SAPI_RAW_VLOG(1, "Symbol table with %zu entries found", symbol_entries); - SAPI_ASSIGN_OR_RETURN(std::string strtab, ReadSectionContents(symtab.sh_link)); + SAPI_ASSIGN_OR_RETURN(std::string strtab, + ReadSectionContents(symtab.sh_link)); SAPI_ASSIGN_OR_RETURN(std::string symbols, ReadSectionContents(symtab)); result_.symbols_.reserve(result_.symbols_.size() + symbol_entries); for (absl::string_view src = symbols; !src.empty(); @@ -441,7 +442,8 @@ absl::Status ElfParser::ReadImportedLibrariesFromDynamic( absl::StrCat("symtab's strtab too big: ", strtab_section.sh_size)); } auto strtab_end = strtab_section.sh_offset + strtab_section.sh_size; - SAPI_ASSIGN_OR_RETURN(std::string dynamic_entries, ReadSectionContents(dynamic)); + SAPI_ASSIGN_OR_RETURN(std::string dynamic_entries, + ReadSectionContents(dynamic)); for (absl::string_view src = dynamic_entries; !src.empty(); src = src.substr(dynamic.sh_entsize)) { ElfDyn dyn; diff --git a/sandboxed_api/sandbox2/util/minielf_test.cc b/sandboxed_api/sandbox2/util/minielf_test.cc index 1fba53a..c13bf25 100644 --- a/sandboxed_api/sandbox2/util/minielf_test.cc +++ b/sandboxed_api/sandbox2/util/minielf_test.cc @@ -61,7 +61,8 @@ TEST(MinielfTest, SymbolResolutionWorks) { ASSERT_THAT( file::GetContents("/proc/self/maps", &maps_buffer, file::Defaults()), IsOk()); - SAPI_ASSERT_OK_AND_ASSIGN(std::vector maps, ParseProcMaps(maps_buffer)); + SAPI_ASSERT_OK_AND_ASSIGN(std::vector maps, + ParseProcMaps(maps_buffer)); // Find maps entry that covers this entry. uint64_t function_address = reinterpret_cast(ExportedFunctionName); diff --git a/sandboxed_api/tools/clang_generator/emitter.cc b/sandboxed_api/tools/clang_generator/emitter.cc index 3d3b6aa..9f1dd9b 100644 --- a/sandboxed_api/tools/clang_generator/emitter.cc +++ b/sandboxed_api/tools/clang_generator/emitter.cc @@ -54,8 +54,8 @@ constexpr absl::string_view kHeaderProlog = #include "absl/status/status.h" #include "absl/status/statusor.h" #include "sandboxed_api/sandbox.h" -#include "sandboxed_api/vars.h" #include "sandboxed_api/util/status_macros.h" +#include "sandboxed_api/vars.h" )"; constexpr absl::string_view kHeaderEpilog = @@ -299,8 +299,8 @@ absl::StatusOr EmitFunction(const clang::FunctionDecl* decl) { ");\n"); } } - absl::StrAppend(&out, "\nSAPI_RETURN_IF_ERROR(sandbox_->Call(\"", function_name, - "\", &v_ret_"); + absl::StrAppend(&out, "\nSAPI_RETURN_IF_ERROR(sandbox_->Call(\"", + function_name, "\", &v_ret_"); for (const auto& [qual, name] : params) { absl::StrAppend(&out, ", ", IsPointerOrReference(qual) ? "" : "&v_", name); } @@ -412,8 +412,9 @@ void Emitter::CollectFunction(clang::FunctionDecl* decl) { absl::StatusOr Emitter::EmitHeader( const GeneratorOptions& options) { - SAPI_ASSIGN_OR_RETURN(const std::string header, - ::sapi::EmitHeader(functions_, rendered_types_, options)); + SAPI_ASSIGN_OR_RETURN( + const std::string header, + ::sapi::EmitHeader(functions_, rendered_types_, options)); return internal::ReformatGoogleStyle(options.out_file, header); } diff --git a/sandboxed_api/tools/clang_generator/generator_tool.cc b/sandboxed_api/tools/clang_generator/generator_tool.cc index e4b74e6..4a40ab8 100644 --- a/sandboxed_api/tools/clang_generator/generator_tool.cc +++ b/sandboxed_api/tools/clang_generator/generator_tool.cc @@ -134,7 +134,7 @@ absl::Status GeneratorMain(int argc, const char** argv) { SAPI_ASSIGN_OR_RETURN(std::string header, emitter.EmitHeader(options)); SAPI_RETURN_IF_ERROR(sapi::file::SetContents(options.out_file, header, - sapi::file::Defaults())); + sapi::file::Defaults())); return absl::OkStatus(); } diff --git a/sandboxed_api/transaction.cc b/sandboxed_api/transaction.cc index a17c148..7a8372d 100644 --- a/sandboxed_api/transaction.cc +++ b/sandboxed_api/transaction.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "sandboxed_api/transaction.h" + #include "sandboxed_api/util/status_macros.h" namespace sapi { @@ -26,7 +27,8 @@ absl::Status TransactionBase::RunTransactionFunctionInSandbox( // Set the wall-time limit for this transaction run, and clean it up // afterwards, no matter what the result. - SAPI_RETURN_IF_ERROR(sandbox_->SetWallTimeLimit(absl::Seconds(GetTimeLimit()))); + SAPI_RETURN_IF_ERROR( + sandbox_->SetWallTimeLimit(absl::Seconds(GetTimeLimit()))); struct TimeCleanup { ~TimeCleanup() { capture->sandbox_->SetWallTimeLimit(absl::ZeroDuration()).IgnoreError(); diff --git a/sandboxed_api/transaction.h b/sandboxed_api/transaction.h index b194a80..de56289 100644 --- a/sandboxed_api/transaction.h +++ b/sandboxed_api/transaction.h @@ -22,7 +22,6 @@ #include "absl/strings/str_cat.h" #include "absl/time/time.h" #include "sandboxed_api/sandbox.h" -#include "sandboxed_api/util/status_macros.h" #define TRANSACTION_FAIL_IF_NOT(x, y) \ if (!(x)) { \ diff --git a/sandboxed_api/var_abstract.cc b/sandboxed_api/var_abstract.cc index 3ca8077..812691c 100644 --- a/sandboxed_api/var_abstract.cc +++ b/sandboxed_api/var_abstract.cc @@ -19,9 +19,9 @@ #include #include -#include "sandboxed_api/sandbox2/comms.h" #include "absl/strings/str_cat.h" #include "sandboxed_api/rpcchannel.h" +#include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/util/status_macros.h" namespace sapi::v { diff --git a/sandboxed_api/var_array.h b/sandboxed_api/var_array.h index 64a034b..c0c43a4 100644 --- a/sandboxed_api/var_array.h +++ b/sandboxed_api/var_array.h @@ -25,10 +25,10 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "sandboxed_api/rpcchannel.h" +#include "sandboxed_api/util/status_macros.h" #include "sandboxed_api/var_abstract.h" #include "sandboxed_api/var_pointable.h" #include "sandboxed_api/var_ptr.h" -#include "sandboxed_api/util/status_macros.h" namespace sapi::v { diff --git a/sandboxed_api/var_int.cc b/sandboxed_api/var_int.cc index 14fc4d3..da266db 100644 --- a/sandboxed_api/var_int.cc +++ b/sandboxed_api/var_int.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "sandboxed_api/var_int.h" + #include "sandboxed_api/rpcchannel.h" #include "sandboxed_api/util/status_macros.h" diff --git a/sandboxed_api/var_lenval.cc b/sandboxed_api/var_lenval.cc index db76e47..29bbfe3 100644 --- a/sandboxed_api/var_lenval.cc +++ b/sandboxed_api/var_lenval.cc @@ -12,15 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Implementation of sapi::v::LenVal. - #include "sandboxed_api/var_lenval.h" #include #include -#include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/rpcchannel.h" +#include "sandboxed_api/sandbox2/comms.h" +#include "sandboxed_api/util/status_macros.h" namespace sapi::v { diff --git a/sandboxed_api/var_proto.h b/sandboxed_api/var_proto.h index d305449..33753a3 100644 --- a/sandboxed_api/var_proto.h +++ b/sandboxed_api/var_proto.h @@ -25,10 +25,10 @@ #include "absl/memory/memory.h" #include "absl/status/statusor.h" #include "sandboxed_api/proto_helper.h" +#include "sandboxed_api/util/status_macros.h" #include "sandboxed_api/var_lenval.h" #include "sandboxed_api/var_pointable.h" #include "sandboxed_api/var_ptr.h" -#include "sandboxed_api/util/status_macros.h" namespace sapi::v {