From fb81c00fd120de57107cb84594c146bd90b52e25 Mon Sep 17 00:00:00 2001 From: Sandboxed API Team Date: Tue, 28 Sep 2021 05:50:19 -0700 Subject: [PATCH] Replace auto with explicit type declarations PiperOrigin-RevId: 399419917 Change-Id: I4b7acd8ab6e2542e2971b29bed0745378b2b6743 --- .../sandbox2/examples/crc4/crc4sandbox.cc | 4 ++-- .../examples/custom_fork/custom_fork_sandbox.cc | 2 +- .../sandbox2/examples/static/static_sandbox.cc | 2 +- .../sandbox2/examples/tool/sandbox2tool.cc | 14 ++++++++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc b/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc index c3bbbf6..e20419e 100644 --- a/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc +++ b/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc @@ -120,7 +120,7 @@ int main(int argc, char** argv) { // Let the sandboxee run. if (!s2.RunAsync()) { - auto result = s2.AwaitResult(); + sandbox2::Result result = s2.AwaitResult(); LOG(ERROR) << "RunAsync failed: " << result.ToString(); return 2; } @@ -141,7 +141,7 @@ int main(int argc, char** argv) { } } - auto result = s2.AwaitResult(); + sandbox2::Result result = s2.AwaitResult(); if (result.final_status() != sandbox2::Result::OK) { LOG(ERROR) << "Sandbox error: " << result.ToString(); return 3; // e.g. sandbox violation, signal (sigsegv) diff --git a/sandboxed_api/sandbox2/examples/custom_fork/custom_fork_sandbox.cc b/sandboxed_api/sandbox2/examples/custom_fork/custom_fork_sandbox.cc index 27522b2..28ab276 100644 --- a/sandboxed_api/sandbox2/examples/custom_fork/custom_fork_sandbox.cc +++ b/sandboxed_api/sandbox2/examples/custom_fork/custom_fork_sandbox.cc @@ -86,7 +86,7 @@ static int SandboxIteration(sandbox2::ForkClient* fork_client, int32_t i) { CHECK(s2.RunAsync()); // Send integer, which will be returned as the sandboxee's exit code. CHECK(s2.comms()->SendInt32(i)); - auto result = s2.AwaitResult(); + sandbox2::Result result = s2.AwaitResult(); LOG(INFO) << "Final execution status of PID " << s2.GetPid() << ": " << result.ToString(); diff --git a/sandboxed_api/sandbox2/examples/static/static_sandbox.cc b/sandboxed_api/sandbox2/examples/static/static_sandbox.cc index 4f509a5..4ab95a7 100644 --- a/sandboxed_api/sandbox2/examples/static/static_sandbox.cc +++ b/sandboxed_api/sandbox2/examples/static/static_sandbox.cc @@ -140,7 +140,7 @@ int main(int argc, char** argv) { sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); // Let the sandboxee run (synchronously). - auto result = s2.Run(); + sandbox2::Result result = s2.Run(); LOG(INFO) << "Final execution status: " << result.ToString(); diff --git a/sandboxed_api/sandbox2/examples/tool/sandbox2tool.cc b/sandboxed_api/sandbox2/examples/tool/sandbox2tool.cc index f2a2053..0b692d8 100644 --- a/sandboxed_api/sandbox2/examples/tool/sandbox2tool.cc +++ b/sandboxed_api/sandbox2/examples/tool/sandbox2tool.cc @@ -15,7 +15,8 @@ // A simple sandbox2 testing tool. // // Usage: -// sandbox2tool -v=1 -sandbox2_danger_danger_permit_all -logtostderr -- /bin/ls +// sandbox2tool -v=1 -sandbox2tool_resolve_and_add_libraries \ +// -sandbox2_danger_danger_permit_all -logtostderr /bin/ls #include #include @@ -155,12 +156,13 @@ int main(int argc, char** argv) { builder.AddTmpfs("/tmp"); } - auto mounts_string = absl::GetFlag(FLAGS_sandbox2tool_additional_bind_mounts); + std::string mounts_string = + absl::GetFlag(FLAGS_sandbox2tool_additional_bind_mounts); if (!mounts_string.empty()) { - for (auto mount : absl::StrSplit(mounts_string, ',')) { + for (absl::string_view mount : absl::StrSplit(mounts_string, ',')) { std::vector source_target = absl::StrSplit(mount, "=>"); - auto source = source_target[0]; - auto target = source_target[0]; + std::string source = source_target[0]; + std::string target = source_target[0]; if (source_target.size() == 2) { target = source_target[1]; } @@ -218,7 +220,7 @@ int main(int argc, char** argv) { LOG(ERROR) << "Sandbox failed"; } - auto result = s2.AwaitResult(); + sandbox2::Result result = s2.AwaitResult(); if (result.final_status() != sandbox2::Result::OK) { LOG(ERROR) << "Sandbox error: " << result.ToString();