Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ package(

cf_cc_binary(
name = "casimir_control_server",
srcs = [
"main.cpp",
],
clang_format_enabled = False,
srcs = ["main.cpp"],
deps = [
":libcasimir",
":libcasimir_control_server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
#include <string>
#include <vector>

#include <gflags/gflags.h>
#include <google/protobuf/empty.pb.h>
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/health_check_service_interface.h>
#include "absl/log/log.h"
#include "absl/strings/escaping.h"
#include "gflags/gflags.h"
#include "google/protobuf/empty.pb.h"
#include "grpcpp/ext/proto_server_reflection_plugin.h"
#include "grpcpp/grpcpp.h"
#include "grpcpp/health_check_service_interface.h"

#include "cuttlefish/host/commands/casimir_control_server/casimir_control.grpc.pb.h"
#include "cuttlefish/host/commands/casimir_control_server/casimir_controller.h"
Expand Down Expand Up @@ -207,8 +207,8 @@ class CasimirControlServiceImpl final : public CasimirControlService::Service {
std::vector<uint8_t> bytes =
CF_EXPECT(device_->SendApdu(id, std::move(apdu_bytes[i])),
"Failed to send APDU bytes");
std::string resp = absl::BytesToHexString(
std::string_view(reinterpret_cast<const char*>(bytes.data()), bytes.size()));
std::string resp = absl::BytesToHexString(std::string_view(
reinterpret_cast<const char*>(bytes.data()), bytes.size()));
response->add_response_hex_strings(std::move(resp));
}

Expand Down
5 changes: 1 addition & 4 deletions base/cvd/cuttlefish/host/commands/cvdalloc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ cf_cc_library(

cf_cc_binary(
name = "cvdalloc",
srcs = [
"cvdalloc.cpp",
],
clang_format_enabled = False,
srcs = ["cvdalloc.cpp"],
deps = [
":interface",
":privilege",
Expand Down
17 changes: 6 additions & 11 deletions base/cvd/cuttlefish/host/commands/cvdalloc/cvdalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include <unistd.h>

#include <string_view>

#include <android-base/macros.h>
#include "absl/cleanup/cleanup.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"

#include "allocd/alloc_utils.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/fs/shared_select.h"
#include "cuttlefish/host/commands/cvdalloc/interface.h"
#include "cuttlefish/host/commands/cvdalloc/privilege.h"
#include "cuttlefish/host/commands/cvdalloc/sem.h"
Expand Down Expand Up @@ -83,8 +79,8 @@ Result<void> Teardown(int id, std::string_view ethernet_bridge_name,

} // namespace

Result<int> CvdallocMain(int argc, char *argv[]) {
std::vector<char *> args = absl::ParseCommandLine(argc, argv);
Result<int> CvdallocMain(int argc, char* argv[]) {
std::vector<char*> args = absl::ParseCommandLine(argc, argv);

if (absl::GetFlag(FLAGS_id) == 0 || absl::GetFlag(FLAGS_socket) == 0) {
Usage();
Expand All @@ -103,9 +99,7 @@ Result<int> CvdallocMain(int argc, char *argv[]) {
return CF_ERRNO("close: " << StrError(errno));
}

absl::Cleanup shutdown = [sock]() {
sock->Shutdown(SHUT_RDWR);
};
absl::Cleanup shutdown = [sock]() { sock->Shutdown(SHUT_RDWR); };

/*
* Save our current uid, so we can restore it to drop privileges later.
Expand All @@ -131,7 +125,8 @@ Result<int> CvdallocMain(int argc, char *argv[]) {
Teardown(id, kCvdallocEthernetBridgeName, kCvdallocWirelessBridgeName);
};

CF_EXPECT(Allocate(id, kCvdallocEthernetBridgeName, kCvdallocWirelessBridgeName));
CF_EXPECT(
Allocate(id, kCvdallocEthernetBridgeName, kCvdallocWirelessBridgeName));
CF_EXPECT(cvdalloc::Post(sock));

LOG(INFO) << "cvdalloc: waiting to teardown";
Expand All @@ -145,7 +140,7 @@ Result<int> CvdallocMain(int argc, char *argv[]) {

} // namespace cuttlefish

int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
auto res = cuttlefish::CvdallocMain(argc, argv);
if (!res.ok()) {
LOG(ERROR) << "cvdalloc failed: \n" << res.error();
Expand Down
5 changes: 1 addition & 4 deletions base/cvd/cuttlefish/host/commands/defaults/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ package(

cf_cc_binary(
name = "cf_defaults",
srcs = [
"defaults.cpp",
],
clang_format_enabled = False,
srcs = ["defaults.cpp"],
deps = [
"//cuttlefish/common/libs/key_equals_value",
"//cuttlefish/host/libs/web/http_client:curl_http_client",
Expand Down
22 changes: 12 additions & 10 deletions base/cvd/cuttlefish/host/commands/defaults/defaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "cuttlefish/host/libs/web/http_client/curl_http_client.h"
#include "cuttlefish/host/libs/web/http_client/http_string.h"

ABSL_FLAG(std::string, filename, "/usr/lib/cuttlefish-common/etc/cf_defaults", "Output filename.");
ABSL_FLAG(std::string, filename, "/usr/lib/cuttlefish-common/etc/cf_defaults",
"Output filename.");
ABSL_FLAG(std::optional<std::string>, static_defaults_when, std::nullopt,
"Specify a key-value pair as \"<key>=<value>\". "
"The key should be a metadata path, e.g., 'project/project-id'. "
Expand All @@ -48,7 +49,7 @@ Result<std::string> MetadataValue(std::string_view key) {
}

Result<std::pair<std::string, std::string>> ParseKeyValueFlag(
const std::string &flag) {
const std::string& flag) {
std::map<std::string, std::string, std::less<void>> kvs =
CF_EXPECT(ParseKeyEqualsValue(flag));
CF_EXPECT(kvs.size() == 1);
Expand All @@ -62,7 +63,7 @@ Result<std::pair<std::string, std::string>> ParseKeyValueFlag(
* For example, if the flag value is `project/project-id=testing`,
* static defaults will only be used if running in the `testing` project.
*/
Result<bool> UseStaticDefaults(const std::optional<std::string> &flag) {
Result<bool> UseStaticDefaults(const std::optional<std::string>& flag) {
if (!flag.has_value()) {
LOG(INFO) << "Will not use static defaults.";
return false;
Expand All @@ -73,20 +74,21 @@ Result<bool> UseStaticDefaults(const std::optional<std::string> &flag) {
Result<std::pair<std::string, std::string>> kv =
CF_EXPECT(ParseKeyValueFlag(flag.value()),
"Couldn't parse key-value pair to find in metadata, "
"got: " << flag.value());
"got: "
<< flag.value());

/* Does the key exist? If so, then get the value. */
std::string actual =
CF_EXPECT(MetadataValue(kv->first),
"Couldn't get value at metadata path " << kv->first);
std::string expected = kv->second;

/* Is the value expected? */
/* Is the value expected? */
if (actual != expected) {
// No error, but do not use static defaults.
LOG(WARNING) << absl::StrFormat(
"Metadata value for %s unexpected, got: '%s', expected '%s'",
kv->first, actual, expected);
"Metadata value for %s unexpected, got: '%s', expected '%s'", kv->first,
actual, expected);
}
return actual == expected;
}
Expand All @@ -106,8 +108,8 @@ std::map<std::string, std::string> StaticDefaults() {

} // namespace

Result<int> DefaultsMain(int argc, char *argv[]) {
std::vector<char *> args = absl::ParseCommandLine(argc, argv);
Result<int> DefaultsMain(int argc, char* argv[]) {
std::vector<char*> args = absl::ParseCommandLine(argc, argv);

std::string filename = absl::GetFlag(FLAGS_filename);
LOG(INFO) << "Writing to " << filename;
Expand All @@ -132,7 +134,7 @@ Result<int> DefaultsMain(int argc, char *argv[]) {

} // namespace cuttlefish

int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
auto res = cuttlefish::DefaultsMain(argc, argv);
if (!res.ok()) {
LOG(ERROR) << "defaults failed: \n" << res.error();
Expand Down
6 changes: 1 addition & 5 deletions base/cvd/cuttlefish/host/commands/display/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ package(

cf_cc_binary(
name = "cvd_internal_display",
srcs = [
"main.cpp",
],
clang_format_enabled = False,
srcs = ["main.cpp"],
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/utils:files",
Expand All @@ -21,7 +18,6 @@ cf_cc_binary(
"//cuttlefish/host/libs/config:display",
"//cuttlefish/host/libs/vm_manager",
"//cuttlefish/result",
"//libbase",
"@abseil-cpp//absl/base:no_destructor",
],
)
8 changes: 3 additions & 5 deletions base/cvd/cuttlefish/host/commands/display/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#include <vector>

#include "absl/base/no_destructor.h"
#include <android-base/strings.h>

#include "cuttlefish/common/libs/utils/files.h"
#include "cuttlefish/common/libs/utils/tee_logging.h"
#include "cuttlefish/flag_parser/flag.h"
#include "cuttlefish/flag_parser/gflags_compat.h"
#include "cuttlefish/common/libs/utils/tee_logging.h"
#include "cuttlefish/host/libs/command_util/runner/run_cvd.pb.h"
#include "cuttlefish/host/libs/command_util/util.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
Expand Down Expand Up @@ -105,8 +104,7 @@ Result<int> DoHelp(std::vector<std::string>& args) {
return 0;
}

static const absl::NoDestructor<
std::unordered_map<std::string, std::string>>
static const absl::NoDestructor<std::unordered_map<std::string, std::string>>
kSubCommandUsages({
{"add", kAddUsage},
{"list", kListUsage},
Expand Down Expand Up @@ -155,7 +153,7 @@ Result<int> DoRemove(std::vector<std::string>& args) {

std::vector<std::string> displays;
const std::vector<Flag> remove_displays_flags = {
Flag::StringFlag(kDisplayFlag)
Flag::StringFlag(kDisplayFlag)
.Help("Display id of a display to remove.")
.Setter([&](std::string_view arg) -> Result<void> {
displays.emplace_back(arg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ package(

cf_cc_binary(
name = "gnss_grpc_proxy",
srcs = [
"gnss_grpc_proxy.cpp",
],
clang_format_enabled = False,
srcs = ["gnss_grpc_proxy.cpp"],
deps = [
":libcvd_gnss_grpc_proxy",
"//cuttlefish/common/libs/fs",
Expand Down
Loading
Loading