Fix all instances of bugprone-undefined-memory-manipulation

pull/16209/head
ncteisen 6 years ago committed by Noah Eisen
parent 92d1b5c433
commit f8a4aae119
  1. 4
      .clang-tidy
  2. 1
      src/core/ext/filters/client_channel/client_channel.cc
  3. 1
      src/core/lib/surface/channel.cc
  4. 4
      src/core/tsi/alts_transport_security.cc
  5. 0
      test/.clang-tidy
  6. 18
      test/core/end2end/fixtures/http_proxy_fixture.cc
  7. 17
      test/core/end2end/fixtures/proxy.cc

@ -1,6 +1,6 @@
---
Checks: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*'
WarningsAsErrors: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*'
Checks: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*,bugprone-*'
WarningsAsErrors: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*,bugprone-*'
CheckOptions:
- key: readability-function-size.StatementThreshold
value: '450'

@ -457,7 +457,6 @@ get_service_config_from_resolver_result_locked(channel_data* chand) {
grpc_uri* uri = grpc_uri_parse(server_uri, true);
GPR_ASSERT(uri->path[0] != '\0');
service_config_parsing_state parsing_state;
memset(&parsing_state, 0, sizeof(parsing_state));
parsing_state.server_name =
uri->path[0] == '/' ? uri->path + 1 : uri->path;
service_config->ParseGlobalParams(parse_retry_throttle_params,

@ -100,7 +100,6 @@ grpc_channel* grpc_channel_create_with_builder(
return channel;
}
memset(channel, 0, sizeof(*channel));
channel->target = target;
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
size_t channel_tracer_max_nodes = 0; // default to off

@ -45,7 +45,9 @@ void grpc_tsi_alts_signal_for_cq_destroy() {
}
void grpc_tsi_alts_init() {
memset(&g_alts_resource, 0, sizeof(alts_shared_resource));
g_alts_resource.channel = nullptr;
g_alts_resource.cq = nullptr;
g_alts_resource.is_cq_drained = false;
gpr_mu_init(&g_alts_resource.mu);
gpr_cv_init(&g_alts_resource.cv);
}

@ -52,6 +52,16 @@
#include "test/core/util/port.h"
struct grpc_end2end_http_proxy {
grpc_end2end_http_proxy()
: proxy_name(nullptr),
server(nullptr),
channel_args(nullptr),
mu(nullptr),
pollset(nullptr),
combiner(nullptr) {
gpr_ref_init(&users, 1);
combiner = grpc_combiner_create();
}
char* proxy_name;
grpc_core::Thread thd;
grpc_tcp_server* server;
@ -519,11 +529,7 @@ static void thread_main(void* arg) {
grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_channel_args* args) {
grpc_core::ExecCtx exec_ctx;
grpc_end2end_http_proxy* proxy =
static_cast<grpc_end2end_http_proxy*>(gpr_malloc(sizeof(*proxy)));
memset(proxy, 0, sizeof(*proxy));
proxy->combiner = grpc_combiner_create();
gpr_ref_init(&proxy->users, 1);
grpc_end2end_http_proxy* proxy = grpc_core::New<grpc_end2end_http_proxy>();
// Construct proxy address.
const int proxy_port = grpc_pick_unused_port_or_die();
gpr_join_host_port(&proxy->proxy_name, "localhost", proxy_port);
@ -573,7 +579,7 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset,
grpc_schedule_on_exec_ctx));
GRPC_COMBINER_UNREF(proxy->combiner, "test");
gpr_free(proxy);
grpc_core::Delete(proxy);
}
const char* grpc_end2end_http_proxy_get_proxy_name(

@ -30,6 +30,17 @@
#include "test/core/util/port.h"
struct grpc_end2end_proxy {
grpc_end2end_proxy()
: proxy_port(nullptr),
server_port(nullptr),
cq(nullptr),
server(nullptr),
client(nullptr),
shutdown(false),
new_call(nullptr) {
memset(&new_call_details, 0, sizeof(new_call_details));
memset(&new_call_metadata, 0, sizeof(new_call_metadata));
}
grpc_core::Thread thd;
char* proxy_port;
char* server_port;
@ -79,9 +90,7 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();
grpc_end2end_proxy* proxy =
static_cast<grpc_end2end_proxy*>(gpr_malloc(sizeof(*proxy)));
memset(proxy, 0, sizeof(*proxy));
grpc_end2end_proxy* proxy = grpc_core::New<grpc_end2end_proxy>();
gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port);
gpr_join_host_port(&proxy->server_port, "localhost", server_port);
@ -128,7 +137,7 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) {
grpc_channel_destroy(proxy->client);
grpc_completion_queue_destroy(proxy->cq);
grpc_call_details_destroy(&proxy->new_call_details);
gpr_free(proxy);
grpc_core::Delete(proxy);
}
static void unrefpc(proxy_call* pc, const char* reason) {

Loading…
Cancel
Save