Added readability-redundant-string-cstr (#31707)
* Added readability-redundant-string-cstr * Auto fix * No need to wrap std::string
This commit is contained in:
parent
7e850a101f
commit
f3fedae7c8
|
|
@ -120,6 +120,7 @@ Checks: '-*,
|
|||
readability-redundant-control-flow,
|
||||
readability-redundant-function-ptr-dereference,
|
||||
readability-redundant-smartptr-get,
|
||||
readability-redundant-string-cstr,
|
||||
readability-redundant-string-init,
|
||||
readability-simplify-boolean-expr,
|
||||
readability-static-definition-in-anonymous-namespace,
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ void JsonWriter::ValueString(const std::string& string) {
|
|||
void JsonWriter::DumpObject(const Json::Object& object) {
|
||||
ContainerBegins(Json::Type::OBJECT);
|
||||
for (const auto& p : object) {
|
||||
ObjectKey(p.first.data());
|
||||
ObjectKey(p.first);
|
||||
DumpValue(p.second);
|
||||
}
|
||||
ContainerEnds(Json::Type::OBJECT);
|
||||
|
|
|
|||
|
|
@ -768,7 +768,7 @@ static void cq_end_op_for_pluck(
|
|||
|
||||
if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) ||
|
||||
(GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && !error.ok())) {
|
||||
std::string errmsg = grpc_core::StatusToString(error).c_str();
|
||||
std::string errmsg = grpc_core::StatusToString(error);
|
||||
GRPC_API_TRACE(
|
||||
"cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, "
|
||||
"done=%p, done_arg=%p, storage=%p)",
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ void ExternalConnectionAcceptorImpl::Start() {
|
|||
}
|
||||
|
||||
void ExternalConnectionAcceptorImpl::SetToChannelArgs(ChannelArguments* args) {
|
||||
args->SetPointer(name_.c_str(), &handler_);
|
||||
args->SetPointer(name_, &handler_);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ class FakeHandshakeServer {
|
|||
0 /* expected max concurrent rpcs unset */);
|
||||
}
|
||||
grpc::ServerBuilder builder;
|
||||
builder.AddListeningPort(address_.c_str(),
|
||||
grpc::InsecureServerCredentials());
|
||||
builder.AddListeningPort(address_, grpc::InsecureServerCredentials());
|
||||
builder.RegisterService(service_.get());
|
||||
// TODO(apolcyn): when removing the global concurrent handshake limiting
|
||||
// queue, set MAX_CONCURRENT_STREAMS on this server.
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ class RlsEnd2endTest : public ::testing::Test {
|
|||
nullptr));
|
||||
call_creds->Unref();
|
||||
channel_creds->Unref();
|
||||
channel_ = grpc::CreateCustomChannel(
|
||||
absl::StrCat("fake:///", kServerName).c_str(), std::move(creds), args);
|
||||
channel_ = grpc::CreateCustomChannel(absl::StrCat("fake:///", kServerName),
|
||||
std::move(creds), args);
|
||||
stub_ = grpc::testing::EchoTestService::NewStub(channel_);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -793,7 +793,7 @@ std::shared_ptr<Channel> XdsEnd2endTest::CreateChannel(
|
|||
// same thing for the response generator to use for the xDS
|
||||
// channel and the xDS resource-does-not-exist timeout value.
|
||||
args->SetString(GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG,
|
||||
bootstrap_.c_str());
|
||||
bootstrap_);
|
||||
args->SetPointerWithVtable(
|
||||
GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_CLIENT_CHANNEL_ARGS,
|
||||
&xds_channel_args_, &kChannelArgsArgVtable);
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ bool InteropClient::DoComputeEngineCreds(
|
|||
gpr_log(GPR_DEBUG, "Got username %s", response.username().c_str());
|
||||
gpr_log(GPR_DEBUG, "Got oauth_scope %s", response.oauth_scope().c_str());
|
||||
GPR_ASSERT(!response.username().empty());
|
||||
GPR_ASSERT(response.username().c_str() == default_service_account);
|
||||
GPR_ASSERT(response.username() == default_service_account);
|
||||
GPR_ASSERT(!response.oauth_scope().empty());
|
||||
const char* oauth_scope_str = response.oauth_scope().c_str();
|
||||
GPR_ASSERT(absl::StrContains(oauth_scope, oauth_scope_str));
|
||||
|
|
@ -314,7 +314,7 @@ bool InteropClient::DoGoogleDefaultCredentials(
|
|||
|
||||
gpr_log(GPR_DEBUG, "Got username %s", response.username().c_str());
|
||||
GPR_ASSERT(!response.username().empty());
|
||||
GPR_ASSERT(response.username().c_str() == default_service_account);
|
||||
GPR_ASSERT(response.username() == default_service_account);
|
||||
gpr_log(GPR_DEBUG, "Large unary rpc with GoogleDefaultCredentials done.");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ static bool QpsDriver() {
|
|||
json = std::string(data, data + len);
|
||||
delete[] data;
|
||||
} else if (scjson) {
|
||||
json = absl::GetFlag(FLAGS_scenarios_json).c_str();
|
||||
json = absl::GetFlag(FLAGS_scenarios_json);
|
||||
} else if (absl::GetFlag(FLAGS_quit)) {
|
||||
return RunQuit(absl::GetFlag(FLAGS_credential_type),
|
||||
per_worker_credential_types);
|
||||
|
|
@ -264,7 +264,7 @@ static bool QpsDriver() {
|
|||
|
||||
// Parse into an array of scenarios
|
||||
Scenarios scenarios;
|
||||
ParseJson(json.c_str(), "grpc.testing.Scenarios", &scenarios);
|
||||
ParseJson(json, "grpc.testing.Scenarios", &scenarios);
|
||||
bool success = true;
|
||||
|
||||
// Make sure that there is at least some valid scenario here
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ QpsWorker::QpsWorker(int driver_port, int server_port,
|
|||
if (driver_port >= 0) {
|
||||
std::string server_address = grpc_core::JoinHostPort("::", driver_port);
|
||||
builder->AddListeningPort(
|
||||
server_address.c_str(),
|
||||
server_address,
|
||||
GetCredentialsProvider()->GetServerCredentials(credential_type));
|
||||
}
|
||||
builder->RegisterService(impl_.get());
|
||||
|
|
|
|||
|
|
@ -81,9 +81,8 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
|
|||
// Negative port number means inproc server, so no listen port needed
|
||||
if (port_num >= 0) {
|
||||
std::string server_address = grpc_core::JoinHostPort("::", port_num);
|
||||
builder->AddListeningPort(server_address.c_str(),
|
||||
Server::CreateServerCredentials(config),
|
||||
&port_num);
|
||||
builder->AddListeningPort(
|
||||
server_address, Server::CreateServerCredentials(config), &port_num);
|
||||
}
|
||||
|
||||
register_service(builder.get(), &async_service_);
|
||||
|
|
|
|||
|
|
@ -103,9 +103,8 @@ class CallbackServer final : public grpc::testing::Server {
|
|||
// Negative port number means inproc server, so no listen port needed
|
||||
if (port_num >= 0) {
|
||||
std::string server_address = grpc_core::JoinHostPort("::", port_num);
|
||||
builder->AddListeningPort(server_address.c_str(),
|
||||
Server::CreateServerCredentials(config),
|
||||
&port_num);
|
||||
builder->AddListeningPort(
|
||||
server_address, Server::CreateServerCredentials(config), &port_num);
|
||||
}
|
||||
|
||||
ApplyConfigToBuilder(config, builder.get());
|
||||
|
|
|
|||
|
|
@ -161,9 +161,8 @@ class SynchronousServer final : public grpc::testing::Server {
|
|||
// Negative port number means inproc server, so no listen port needed
|
||||
if (port_num >= 0) {
|
||||
std::string server_address = grpc_core::JoinHostPort("::", port_num);
|
||||
builder->AddListeningPort(server_address.c_str(),
|
||||
Server::CreateServerCredentials(config),
|
||||
&port_num);
|
||||
builder->AddListeningPort(
|
||||
server_address, Server::CreateServerCredentials(config), &port_num);
|
||||
}
|
||||
|
||||
ApplyConfigToBuilder(config, builder.get());
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ std::shared_ptr<grpc::Channel> CreateCliChannel(
|
|||
}
|
||||
if (!absl::GetFlag(FLAGS_default_service_config).empty()) {
|
||||
args.SetString(GRPC_ARG_SERVICE_CONFIG,
|
||||
absl::GetFlag(FLAGS_default_service_config).c_str());
|
||||
absl::GetFlag(FLAGS_default_service_config));
|
||||
}
|
||||
// See |GRPC_ARG_MAX_METADATA_SIZE| in |grpc_types.h|.
|
||||
// Set to large enough size (10M) that should work for most use cases.
|
||||
|
|
@ -319,7 +319,7 @@ int GrpcToolMainLib(int argc, const char** argv, const CliCredentials& cred,
|
|||
const bool ok = cmd->function(&grpc_tool, argc, argv, cred, callback);
|
||||
return ok ? 0 : 1;
|
||||
} else {
|
||||
Usage("Invalid command '" + std::string(command.c_str()) + "'");
|
||||
Usage("Invalid command '" + command + "'");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue