aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-08-01 08:36:03 -0700
committerGravatar Noah Eisen <ncteisen@google.com>2018-08-29 14:24:02 -0700
commitf8a4aae1197e586d5c34f1acff450eac4d764c4b (patch)
treeb8c32ef184f70f198f9001d2384499e1d206a882
parent92d1b5c433b69834b943107c76e6917556c4903f (diff)
Fix all instances of bugprone-undefined-memory-manipulation
-rw-r--r--.clang-tidy4
-rw-r--r--src/core/ext/filters/client_channel/client_channel.cc1
-rw-r--r--src/core/lib/surface/channel.cc1
-rw-r--r--src/core/tsi/alts_transport_security.cc4
-rw-r--r--test/.clang-tidy (renamed from test/cpp/util/.clang-tidy)0
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc18
-rw-r--r--test/core/end2end/fixtures/proxy.cc17
7 files changed, 30 insertions, 15 deletions
diff --git a/.clang-tidy b/.clang-tidy
index fbf0b6541e..d217441792 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -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'
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index b06f09d8c7..b2275441e5 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -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,
diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc
index 82635d3c21..e3dde51d69 100644
--- a/src/core/lib/surface/channel.cc
+++ b/src/core/lib/surface/channel.cc
@@ -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
diff --git a/src/core/tsi/alts_transport_security.cc b/src/core/tsi/alts_transport_security.cc
index 2fd408103b..dac23bbf7a 100644
--- a/src/core/tsi/alts_transport_security.cc
+++ b/src/core/tsi/alts_transport_security.cc
@@ -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);
}
diff --git a/test/cpp/util/.clang-tidy b/test/.clang-tidy
index f951ee5fea..f951ee5fea 100644
--- a/test/cpp/util/.clang-tidy
+++ b/test/.clang-tidy
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index f02fa9d998..6f444bf66a 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -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(
diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc
index 042c858b4c..869b6e846d 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -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) {