Skip to content

Commit

Permalink
Manual fixes to enable performance- clang tidy checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ncteisen committed Jun 14, 2018
1 parent 58e0cbf commit 373fc6d
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 55 deletions.
4 changes: 2 additions & 2 deletions test/cpp/codegen/golden_file_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ DEFINE_string(
const char kGoldenFilePath[] = "test/cpp/codegen/compiler_test_golden";
const char kMockGoldenFilePath[] = "test/cpp/codegen/compiler_test_mock_golden";

void run_test(std::basic_string<char> generated_file,
std::basic_string<char> golden_file) {
void run_test(const std::basic_string<char>& generated_file,
const std::basic_string<char>& golden_file) {
std::ifstream generated(generated_file);
std::ifstream golden(golden_file);

Expand Down
14 changes: 7 additions & 7 deletions test/cpp/end2end/async_end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) {
cq_.get(), tag(2));
Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata();
const auto& client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second,
ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
Expand Down Expand Up @@ -937,7 +937,7 @@ TEST_P(AsyncEnd2endTest, ServerInitialMetadataRpc) {
srv_ctx.AddInitialMetadata(meta2.first, meta2.second);
response_writer.SendInitialMetadata(tag(3));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
const auto& server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta1.second,
ToString(server_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
Expand Down Expand Up @@ -990,7 +990,7 @@ TEST_P(AsyncEnd2endTest, ServerTrailingMetadataRpc) {

EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok());
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
const auto& server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta1.second,
ToString(server_trailing_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
Expand Down Expand Up @@ -1038,7 +1038,7 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
cq_.get(), tag(2));
Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata();
const auto& client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second,
ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
Expand All @@ -1049,7 +1049,7 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
srv_ctx.AddInitialMetadata(meta4.first, meta4.second);
response_writer.SendInitialMetadata(tag(3));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
const auto& server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta3.second,
ToString(server_initial_metadata.find(meta3.first)->second));
EXPECT_EQ(meta4.second,
Expand All @@ -1066,7 +1066,7 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {

EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok());
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
const auto& server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta5.second,
ToString(server_trailing_metadata.find(meta5.first)->second));
EXPECT_EQ(meta6.second,
Expand Down Expand Up @@ -1144,7 +1144,7 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) {

TEST_P(AsyncEnd2endTest, UnimplementedRpc) {
ChannelArguments args;
auto channel_creds = GetCredentialsProvider()->GetChannelCredentials(
const auto& channel_creds = GetCredentialsProvider()->GetChannelCredentials(
GetParam().credentials_type, &args);
std::shared_ptr<Channel> channel =
!(GetParam().inproc)
Expand Down
11 changes: 6 additions & 5 deletions test/cpp/interop/http2_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ const int kLargeRequestSize = 271828;
const int kLargeResponseSize = 314159;
} // namespace

Http2Client::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel)
: channel_(channel) {
Http2Client::ServiceStub::ServiceStub(const std::shared_ptr<Channel>& channel)
: channel_(std::move(channel)) {
stub_ = TestService::NewStub(channel);
}

TestService::Stub* Http2Client::ServiceStub::Get() { return stub_.get(); }

Http2Client::Http2Client(std::shared_ptr<Channel> channel)
Http2Client::Http2Client(const std::shared_ptr<Channel>& channel)
: serviceStub_(channel),
channel_(channel),
channel_(std::move(channel)),
defaultRequest_(BuildDefaultRequest()) {}

bool Http2Client::AssertStatusCode(const Status& s, StatusCode expected_code) {
Expand Down Expand Up @@ -140,7 +140,8 @@ bool Http2Client::DoPing() {
return true;
}

void Http2Client::MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel) {
void Http2Client::MaxStreamsWorker(
const std::shared_ptr<grpc::Channel>& channel) {
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::OK);
GPR_ASSERT(response.payload().body() ==
Expand Down
6 changes: 3 additions & 3 deletions test/cpp/interop/http2_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace testing {

class Http2Client {
public:
explicit Http2Client(std::shared_ptr<Channel> channel);
explicit Http2Client(const std::shared_ptr<Channel>& channel);
~Http2Client() {}

bool DoRstAfterHeader();
Expand All @@ -44,7 +44,7 @@ class Http2Client {
private:
class ServiceStub {
public:
ServiceStub(std::shared_ptr<Channel> channel);
ServiceStub(const std::shared_ptr<Channel>& channel);

TestService::Stub* Get();

Expand All @@ -53,7 +53,7 @@ class Http2Client {
std::shared_ptr<Channel> channel_;
};

void MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel);
void MaxStreamsWorker(const std::shared_ptr<grpc::Channel>& channel);
bool AssertStatusCode(const Status& s, StatusCode expected_code);
Status SendUnaryCall(SimpleResponse* response);
SimpleRequest BuildDefaultRequest();
Expand Down
4 changes: 2 additions & 2 deletions test/cpp/interop/interop_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ void InteropClient::ServiceStub::Reset(
}
}

void InteropClient::Reset(std::shared_ptr<Channel> channel) {
void InteropClient::Reset(const std::shared_ptr<Channel>& channel) {
serviceStub_.Reset(std::move(channel));
}

InteropClient::InteropClient(std::shared_ptr<Channel> channel,
InteropClient::InteropClient(const std::shared_ptr<Channel>& channel,
bool new_stub_every_test_case,
bool do_not_abort_on_transient_failures)
: serviceStub_(std::move(channel), new_stub_every_test_case),
Expand Down
4 changes: 2 additions & 2 deletions test/cpp/interop/interop_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class InteropClient {
/// created for every test case
/// If do_not_abort_on_transient_failures is true, abort() is not called in
/// case of transient failures (like connection failures)
explicit InteropClient(std::shared_ptr<Channel> channel,
explicit InteropClient(const std::shared_ptr<Channel>& channel,
bool new_stub_every_test_case,
bool do_not_abort_on_transient_failures);
~InteropClient() {}

void Reset(std::shared_ptr<Channel> channel);
void Reset(const std::shared_ptr<Channel>& channel);

bool DoEmpty();
bool DoLargeUnary();
Expand Down
8 changes: 4 additions & 4 deletions test/cpp/interop/interop_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,25 +317,25 @@ class TestServiceImpl : public TestService::Service {
};

void grpc::testing::interop::RunServer(
std::shared_ptr<ServerCredentials> creds) {
const std::shared_ptr<ServerCredentials>& creds) {
RunServer(creds, FLAGS_port, nullptr, nullptr);
}

void grpc::testing::interop::RunServer(
std::shared_ptr<ServerCredentials> creds,
const std::shared_ptr<ServerCredentials>& creds,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options) {
RunServer(creds, FLAGS_port, nullptr, std::move(server_options));
}

void grpc::testing::interop::RunServer(
std::shared_ptr<ServerCredentials> creds, const int port,
const std::shared_ptr<ServerCredentials>& creds, const int port,
ServerStartedCondition* server_started_condition) {
RunServer(creds, port, server_started_condition, nullptr);
}

void grpc::testing::interop::RunServer(
std::shared_ptr<ServerCredentials> creds, const int port,
const std::shared_ptr<ServerCredentials>& creds, const int port,
ServerStartedCondition* server_started_condition,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options) {
Expand Down
8 changes: 4 additions & 4 deletions test/cpp/interop/server_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ struct ServerStartedCondition {
/// Run gRPC interop server using port FLAGS_port.
///
/// \param creds The credentials associated with the server.
void RunServer(std::shared_ptr<ServerCredentials> creds);
void RunServer(const std::shared_ptr<ServerCredentials>& creds);

/// Run gRPC interop server.
///
/// \param creds The credentials associated with the server.
/// \param port Port to use for the server.
/// \param server_started_condition (optional) Struct holding mutex, condition
/// variable, and condition used to notify when the server has started.
void RunServer(std::shared_ptr<ServerCredentials> creds, int port,
void RunServer(const std::shared_ptr<ServerCredentials>& creds, int port,
ServerStartedCondition* server_started_condition);

/// Run gRPC interop server.
///
/// \param creds The credentials associated with the server.
/// \param server_options List of options to set when building the server.
void RunServer(
std::shared_ptr<ServerCredentials> creds,
const std::shared_ptr<ServerCredentials>& creds,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options);

Expand All @@ -91,7 +91,7 @@ void RunServer(
/// \param server_started_condition (optional) Struct holding mutex, condition
// variable, and condition used to notify when the server has started.
void RunServer(
std::shared_ptr<ServerCredentials> creds, const int port,
const std::shared_ptr<ServerCredentials>& creds, const int port,
ServerStartedCondition* server_started_condition,
std::unique_ptr<std::vector<std::unique_ptr<grpc::ServerBuilderOption>>>
server_options);
Expand Down
6 changes: 3 additions & 3 deletions test/cpp/naming/resolver_component_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace {
class GrpcLBAddress final {
public:
GrpcLBAddress(std::string address, bool is_balancer)
: is_balancer(is_balancer), address(address) {}
: is_balancer(is_balancer), address(std::move(address)) {}

bool operator==(const GrpcLBAddress& other) const {
return this->is_balancer == other.is_balancer &&
Expand All @@ -109,7 +109,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) {
std::vector<GrpcLBAddress> out;
while (expected_addrs.size() != 0) {
// get the next <ip>,<port> (v4 or v6)
size_t next_comma = expected_addrs.find(",");
size_t next_comma = expected_addrs.find(',');
if (next_comma == std::string::npos) {
gpr_log(GPR_ERROR,
"Missing ','. Expected_addrs arg should be a semicolon-separated "
Expand All @@ -120,7 +120,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) {
std::string next_addr = expected_addrs.substr(0, next_comma);
expected_addrs = expected_addrs.substr(next_comma + 1, std::string::npos);
// get the next is_balancer 'bool' associated with this address
size_t next_semicolon = expected_addrs.find(";");
size_t next_semicolon = expected_addrs.find(';');
bool is_balancer =
gpr_is_true(expected_addrs.substr(0, next_semicolon).c_str());
out.emplace_back(GrpcLBAddress(next_addr, is_balancer));
Expand Down
26 changes: 13 additions & 13 deletions test/cpp/naming/resolver_component_tests_runner_invoker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,21 @@ namespace grpc {

namespace testing {

void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path,
std::string test_bin_path,
std::string dns_server_bin_path,
std::string records_config_path,
std::string dns_resolver_bin_path,
std::string tcp_connect_bin_path) {
void InvokeResolverComponentTestsRunner(
std::string test_runner_bin_path, const std::string& test_bin_path,
const std::string& dns_server_bin_path,
const std::string& records_config_path,
const std::string& dns_resolver_bin_path,
const std::string& tcp_connect_bin_path) {
int dns_server_port = grpc_pick_unused_port_or_die();

SubProcess* test_driver =
new SubProcess({test_runner_bin_path, "--test_bin_path=" + test_bin_path,
"--dns_server_bin_path=" + dns_server_bin_path,
"--records_config_path=" + records_config_path,
"--dns_server_port=" + std::to_string(dns_server_port),
"--dns_resolver_bin_path=" + dns_resolver_bin_path,
"--tcp_connect_bin_path=" + tcp_connect_bin_path});
SubProcess* test_driver = new SubProcess(
{std::move(test_runner_bin_path), "--test_bin_path=" + test_bin_path,
"--dns_server_bin_path=" + dns_server_bin_path,
"--records_config_path=" + records_config_path,
"--dns_server_port=" + std::to_string(dns_server_port),
"--dns_resolver_bin_path=" + dns_resolver_bin_path,
"--tcp_connect_bin_path=" + tcp_connect_bin_path});
gpr_mu test_driver_mu;
gpr_mu_init(&test_driver_mu);
gpr_cv test_driver_cv;
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/qps/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class ClientImpl : public Client {

private:
void set_channel_args(const ClientConfig& config, ChannelArguments* args) {
for (auto channel_arg : config.channel_args()) {
for (const auto& channel_arg : config.channel_args()) {
if (channel_arg.value_case() == ChannelArg::kStrValue) {
args->SetString(channel_arg.name(), channel_arg.str_value());
} else if (channel_arg.value_case() == ChannelArg::kIntValue) {
Expand Down
14 changes: 7 additions & 7 deletions test/cpp/qps/client_async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
};

static std::unique_ptr<BenchmarkService::Stub> BenchmarkStubCreator(
std::shared_ptr<Channel> ch) {
const std::shared_ptr<Channel>& ch) {
return BenchmarkService::NewStub(ch);
}

Expand All @@ -314,7 +314,7 @@ class AsyncUnaryClient final
~AsyncUnaryClient() override {}

private:
static void CheckDone(grpc::Status s, SimpleResponse* response,
static void CheckDone(const grpc::Status& s, SimpleResponse* response,
HistogramEntry* entry) {
entry->set_status(s.error_code());
}
Expand Down Expand Up @@ -498,7 +498,7 @@ class AsyncStreamingPingPongClient final
~AsyncStreamingPingPongClient() override {}

private:
static void CheckDone(grpc::Status s, SimpleResponse* response) {}
static void CheckDone(const grpc::Status& s, SimpleResponse* response) {}
static std::unique_ptr<
grpc::ClientAsyncReaderWriter<SimpleRequest, SimpleResponse>>
PrepareReq(BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
Expand Down Expand Up @@ -630,7 +630,7 @@ class AsyncStreamingFromClientClient final
~AsyncStreamingFromClientClient() override {}

private:
static void CheckDone(grpc::Status s, SimpleResponse* response) {}
static void CheckDone(const grpc::Status& s, SimpleResponse* response) {}
static std::unique_ptr<grpc::ClientAsyncWriter<SimpleRequest>> PrepareReq(
BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
SimpleResponse* resp, CompletionQueue* cq) {
Expand Down Expand Up @@ -745,7 +745,7 @@ class AsyncStreamingFromServerClient final
~AsyncStreamingFromServerClient() override {}

private:
static void CheckDone(grpc::Status s, SimpleResponse* response) {}
static void CheckDone(const grpc::Status& s, SimpleResponse* response) {}
static std::unique_ptr<grpc::ClientAsyncReader<SimpleResponse>> PrepareReq(
BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
const SimpleRequest& req, CompletionQueue* cq) {
Expand Down Expand Up @@ -895,7 +895,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
};

static std::unique_ptr<grpc::GenericStub> GenericStubCreator(
std::shared_ptr<Channel> ch) {
const std::shared_ptr<Channel>& ch) {
return std::unique_ptr<grpc::GenericStub>(new grpc::GenericStub(ch));
}

Expand All @@ -911,7 +911,7 @@ class GenericAsyncStreamingClient final
~GenericAsyncStreamingClient() override {}

private:
static void CheckDone(grpc::Status s, ByteBuffer* response) {}
static void CheckDone(const grpc::Status& s, ByteBuffer* response) {}
static std::unique_ptr<grpc::GenericClientAsyncReaderWriter> PrepareReq(
grpc::GenericStub* stub, grpc::ClientContext* ctx,
const grpc::string& method_name, CompletionQueue* cq) {
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/qps/client_sync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace grpc {
namespace testing {

static std::unique_ptr<BenchmarkService::Stub> BenchmarkStubCreator(
std::shared_ptr<Channel> ch) {
const std::shared_ptr<Channel>& ch) {
return BenchmarkService::NewStub(ch);
}

Expand Down
1 change: 0 additions & 1 deletion test/cpp/qps/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ std::unique_ptr<ScenarioResult> RunScenario(
// To be added to the result, containing the final configuration used for
// client and config (including host, etc.)
ClientConfig result_client_config;
const ServerConfig& result_server_config = initial_server_config;

// Get client, server lists; ignore if inproc test
auto workers = (!run_inproc) ? get_workers("QPS_WORKERS") : deque<string>();
Expand Down

0 comments on commit 373fc6d

Please sign in to comment.