aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/transport/chttp2
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ext/transport/chttp2')
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.cc24
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc16
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc10
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc60
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc16
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc7
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc8
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc184
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.cc26
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.cc4
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.cc4
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc6
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.cc26
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc38
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_lists.cc12
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.cc21
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc41
19 files changed, 255 insertions, 252 deletions
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
index 6cd476f4ca..77cc313480 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
@@ -68,7 +68,7 @@ static void chttp2_connector_unref(grpc_exec_ctx* exec_ctx,
gpr_mu_destroy(&c->mu);
// If handshaking is not yet in progress, destroy the endpoint.
// Otherwise, the handshaker will do this for us.
- if (c->endpoint != NULL) grpc_endpoint_destroy(exec_ctx, c->endpoint);
+ if (c->endpoint != nullptr) grpc_endpoint_destroy(exec_ctx, c->endpoint);
gpr_free(c);
}
}
@@ -78,13 +78,13 @@ static void chttp2_connector_shutdown(grpc_exec_ctx* exec_ctx,
chttp2_connector* c = (chttp2_connector*)con;
gpr_mu_lock(&c->mu);
c->shutdown = true;
- if (c->handshake_mgr != NULL) {
+ if (c->handshake_mgr != nullptr) {
grpc_handshake_manager_shutdown(exec_ctx, c->handshake_mgr,
GRPC_ERROR_REF(why));
}
// If handshaking is not yet in progress, shutdown the endpoint.
// Otherwise, the handshaker will do this for us.
- if (!c->connecting && c->endpoint != NULL) {
+ if (!c->connecting && c->endpoint != nullptr) {
grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(why));
}
gpr_mu_unlock(&c->mu);
@@ -125,10 +125,10 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
c->result->channel_args = args->args;
}
grpc_closure* notify = c->notify;
- c->notify = NULL;
+ c->notify = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
- c->handshake_mgr = NULL;
+ c->handshake_mgr = nullptr;
gpr_mu_unlock(&c->mu);
chttp2_connector_unref(exec_ctx, (grpc_connector*)c);
}
@@ -142,8 +142,8 @@ static void start_handshake_locked(grpc_exec_ctx* exec_ctx,
c->args.interested_parties);
grpc_handshake_manager_do_handshake(
exec_ctx, c->handshake_mgr, c->endpoint, c->args.channel_args,
- c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
- c->endpoint = NULL; // Endpoint handed off to handshake manager.
+ c->args.deadline, nullptr /* acceptor */, on_handshake_done, c);
+ c->endpoint = nullptr; // Endpoint handed off to handshake manager.
}
static void connected(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
@@ -159,15 +159,15 @@ static void connected(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
}
memset(c->result, 0, sizeof(*c->result));
grpc_closure* notify = c->notify;
- c->notify = NULL;
+ c->notify = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
- if (c->endpoint != NULL) {
+ if (c->endpoint != nullptr) {
grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(error));
}
gpr_mu_unlock(&c->mu);
chttp2_connector_unref(exec_ctx, (grpc_connector*)arg);
} else {
- GPR_ASSERT(c->endpoint != NULL);
+ GPR_ASSERT(c->endpoint != nullptr);
start_handshake_locked(exec_ctx, c);
gpr_mu_unlock(&c->mu);
}
@@ -182,11 +182,11 @@ static void chttp2_connector_connect(grpc_exec_ctx* exec_ctx,
grpc_resolved_address addr;
grpc_get_subchannel_address_arg(exec_ctx, args->channel_args, &addr);
gpr_mu_lock(&c->mu);
- GPR_ASSERT(c->notify == NULL);
+ GPR_ASSERT(c->notify == nullptr);
c->notify = notify;
c->args = *args;
c->result = result;
- GPR_ASSERT(c->endpoint == NULL);
+ GPR_ASSERT(c->endpoint == nullptr);
chttp2_connector_ref(con); // Ref taken for callback.
GRPC_CLOSURE_INIT(&c->connected, connected, c, grpc_schedule_on_exec_ctx);
GPR_ASSERT(!c->connecting);
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index 26c7f0debf..028b69e5ff 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -49,9 +49,9 @@ static grpc_channel* client_channel_factory_create_channel(
grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
const char* target, grpc_client_channel_type type,
const grpc_channel_args* args) {
- if (target == NULL) {
+ if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
- return NULL;
+ return nullptr;
}
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
@@ -62,7 +62,7 @@ static grpc_channel* client_channel_factory_create_channel(
grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1);
gpr_free(arg.value.string);
grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args,
- GRPC_CLIENT_CHANNEL, NULL);
+ GRPC_CLIENT_CHANNEL, nullptr);
grpc_channel_args_destroy(exec_ctx, new_args);
return channel;
}
@@ -86,7 +86,7 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
GRPC_API_TRACE(
"grpc_insecure_channel_create(target=%s, args=%p, reserved=%p)", 3,
(target, args, reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
// Add channel arg containing the client channel factory.
grpc_arg arg =
grpc_client_channel_factory_create_channel_arg(&client_channel_factory);
@@ -98,8 +98,8 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
// Clean up.
grpc_channel_args_destroy(&exec_ctx, new_args);
grpc_exec_ctx_finish(&exec_ctx);
- return channel != NULL ? channel
- : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create client channel");
+ return channel != nullptr ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create client channel");
}
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
index 0974a7c393..e748d28964 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
@@ -58,14 +58,14 @@ grpc_channel* grpc_insecure_channel_create_from_fd(
grpc_channel* channel = grpc_channel_create(
&exec_ctx, target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_channel_args_destroy(&exec_ctx, final_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
- return channel != NULL ? channel
- : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create client channel");
+ return channel != nullptr ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create client channel");
}
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index 68c1e1868c..dd2bc427a7 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -47,51 +47,51 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_exec_ctx* exec_ctx, const grpc_subchannel_args* args) {
grpc_channel_credentials* channel_credentials =
grpc_channel_credentials_find_in_args(args->args);
- if (channel_credentials == NULL) {
+ if (channel_credentials == nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: channel credentials missing for secure "
"channel.");
- return NULL;
+ return nullptr;
}
// Make sure security connector does not already exist in args.
- if (grpc_security_connector_find_in_args(args->args) != NULL) {
+ if (grpc_security_connector_find_in_args(args->args) != nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: security connector already present in "
"channel args.");
- return NULL;
+ return nullptr;
}
// To which address are we connecting? By default, use the server URI.
const grpc_arg* server_uri_arg =
grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
- GPR_ASSERT(server_uri_arg != NULL);
+ GPR_ASSERT(server_uri_arg != nullptr);
GPR_ASSERT(server_uri_arg->type == GRPC_ARG_STRING);
const char* server_uri_str = server_uri_arg->value.string;
- GPR_ASSERT(server_uri_str != NULL);
+ GPR_ASSERT(server_uri_str != nullptr);
grpc_uri* server_uri =
grpc_uri_parse(exec_ctx, server_uri_str, true /* supress errors */);
- GPR_ASSERT(server_uri != NULL);
+ GPR_ASSERT(server_uri != nullptr);
const char* server_uri_path;
server_uri_path =
server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path;
const grpc_slice_hash_table* targets_info =
grpc_lb_targets_info_find_in_args(args->args);
- char* target_name_to_check = NULL;
- if (targets_info != NULL) { // LB channel
+ char* target_name_to_check = nullptr;
+ if (targets_info != nullptr) { // LB channel
// Find the balancer name for the target.
const char* target_uri_str =
grpc_get_subchannel_address_uri_arg(args->args);
grpc_uri* target_uri =
grpc_uri_parse(exec_ctx, target_uri_str, false /* suppress errors */);
- GPR_ASSERT(target_uri != NULL);
+ GPR_ASSERT(target_uri != nullptr);
if (target_uri->path[0] != '\0') { // "path" may be empty
const grpc_slice key = grpc_slice_from_static_string(
target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
const char* value =
(const char*)grpc_slice_hash_table_get(targets_info, key);
- if (value != NULL) target_name_to_check = gpr_strdup(value);
+ if (value != nullptr) target_name_to_check = gpr_strdup(value);
grpc_slice_unref_internal(exec_ctx, key);
}
- if (target_name_to_check == NULL) {
+ if (target_name_to_check == nullptr) {
// If the target name to check hasn't already been set, fall back to using
// SERVER_URI
target_name_to_check = gpr_strdup(server_uri_path);
@@ -101,10 +101,10 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
target_name_to_check = gpr_strdup(server_uri_path);
}
grpc_uri_destroy(server_uri);
- GPR_ASSERT(target_name_to_check != NULL);
- grpc_channel_security_connector* subchannel_security_connector = NULL;
+ GPR_ASSERT(target_name_to_check != nullptr);
+ grpc_channel_security_connector* subchannel_security_connector = nullptr;
// Create the security connector using the credentials and target name.
- grpc_channel_args* new_args_from_connector = NULL;
+ grpc_channel_args* new_args_from_connector = nullptr;
const grpc_security_status security_status =
grpc_channel_credentials_create_security_connector(
exec_ctx, channel_credentials, target_name_to_check, args->args,
@@ -114,18 +114,18 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
"Failed to create secure subchannel for secure name '%s'",
target_name_to_check);
gpr_free(target_name_to_check);
- return NULL;
+ return nullptr;
}
gpr_free(target_name_to_check);
grpc_arg new_security_connector_arg =
grpc_security_connector_to_arg(&subchannel_security_connector->base);
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
- new_args_from_connector != NULL ? new_args_from_connector : args->args,
+ new_args_from_connector != nullptr ? new_args_from_connector : args->args,
&new_security_connector_arg, 1);
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base,
"lb_channel_create");
- if (new_args_from_connector != NULL) {
+ if (new_args_from_connector != nullptr) {
grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
}
grpc_subchannel_args* final_sc_args =
@@ -140,11 +140,11 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
const grpc_subchannel_args* args) {
grpc_subchannel_args* subchannel_args =
get_secure_naming_subchannel_args(exec_ctx, args);
- if (subchannel_args == NULL) {
+ if (subchannel_args == nullptr) {
gpr_log(
GPR_ERROR,
"Failed to create subchannel arguments during subchannel creation.");
- return NULL;
+ return nullptr;
}
grpc_connector* connector = grpc_chttp2_connector_create();
grpc_subchannel* s =
@@ -160,9 +160,9 @@ static grpc_channel* client_channel_factory_create_channel(
grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
const char* target, grpc_client_channel_type type,
const grpc_channel_args* args) {
- if (target == NULL) {
+ if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
- return NULL;
+ return nullptr;
}
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
@@ -173,7 +173,7 @@ static grpc_channel* client_channel_factory_create_channel(
grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1);
gpr_free(arg.value.string);
grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args,
- GRPC_CLIENT_CHANNEL, NULL);
+ GRPC_CLIENT_CHANNEL, nullptr);
grpc_channel_args_destroy(exec_ctx, new_args);
return channel;
}
@@ -199,9 +199,9 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
"reserved=%p)",
4, ((void*)creds, target, (void*)args, (void*)reserved));
- GPR_ASSERT(reserved == NULL);
- grpc_channel* channel = NULL;
- if (creds != NULL) {
+ GPR_ASSERT(reserved == nullptr);
+ grpc_channel* channel = nullptr;
+ if (creds != nullptr) {
// Add channel args containing the client channel factory and channel
// credentials.
grpc_arg args_to_add[] = {
@@ -217,8 +217,8 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
grpc_channel_args_destroy(&exec_ctx, new_args);
grpc_exec_ctx_finish(&exec_ctx);
}
- return channel != NULL ? channel
- : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create secure client channel");
+ return channel != nullptr ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create secure client channel");
}
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
index 98683acc59..93be5e4081 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.cc
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -69,7 +69,7 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
const char* error_str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str);
- if (error == GRPC_ERROR_NONE && args->endpoint != NULL) {
+ if (error == GRPC_ERROR_NONE && args->endpoint != nullptr) {
// We were shut down after handshaking completed successfully, so
// destroy the endpoint here.
// TODO(ctiller): It is currently necessary to shutdown endpoints
@@ -86,7 +86,7 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
// If the handshaking succeeded but there is no endpoint, then the
// handshaker may have handed off the connection to some external
// code, so we can just clean up here without creating a transport.
- if (args->endpoint != NULL) {
+ if (args->endpoint != nullptr) {
grpc_transport* transport =
grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 0);
grpc_server_setup_transport(
@@ -166,7 +166,7 @@ static void tcp_server_shutdown_complete(grpc_exec_ctx* exec_ctx, void* arg,
// Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref.
grpc_exec_ctx_flush(exec_ctx);
- if (destroy_done != NULL) {
+ if (destroy_done != nullptr) {
destroy_done->cb(exec_ctx, destroy_done->cb_arg, GRPC_ERROR_REF(error));
grpc_exec_ctx_flush(exec_ctx);
}
@@ -194,14 +194,14 @@ grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
grpc_server* server, const char* addr,
grpc_channel_args* args,
int* port_num) {
- grpc_resolved_addresses* resolved = NULL;
- grpc_tcp_server* tcp_server = NULL;
+ grpc_resolved_addresses* resolved = nullptr;
+ grpc_tcp_server* tcp_server = nullptr;
size_t i;
size_t count = 0;
int port_temp;
grpc_error* err = GRPC_ERROR_NONE;
- server_state* state = NULL;
- grpc_error** errors = NULL;
+ server_state* state = nullptr;
+ grpc_error** errors = nullptr;
size_t naddrs = 0;
*port_num = -1;
@@ -284,7 +284,7 @@ error:
*port_num = 0;
done:
- if (errors != NULL) {
+ if (errors != nullptr) {
for (i = 0; i < naddrs; i++) {
GRPC_ERROR_UNREF(errors[i]);
}
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
index e37d69e5e9..007d1be50c 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
@@ -36,7 +36,7 @@
void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
void* reserved, int fd) {
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
char* name;
@@ -60,8 +60,9 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
grpc_endpoint_add_to_pollset(&exec_ctx, server_endpoint, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server, transport, NULL, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_server_setup_transport(&exec_ctx, server, transport, nullptr,
+ server_args);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
index 4b2e348780..ac3ea40f47 100644
--- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
@@ -38,16 +38,16 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
grpc_server_credentials* creds) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_error* err = GRPC_ERROR_NONE;
- grpc_server_security_connector* sc = NULL;
+ grpc_server_security_connector* sc = nullptr;
int port_num = 0;
grpc_security_status status;
- grpc_channel_args* args = NULL;
+ grpc_channel_args* args = nullptr;
GRPC_API_TRACE(
"grpc_server_add_secure_http2_port("
"server=%p, addr=%s, creds=%p)",
3, (server, addr, creds));
// Create security context.
- if (creds == NULL) {
+ if (creds == nullptr) {
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"No credentials specified for secure server port (creds==NULL)");
goto done;
@@ -74,7 +74,7 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
// Add server port.
err = grpc_chttp2_server_add_port(&exec_ctx, server, addr, args, &port_num);
done:
- if (sc != NULL) {
+ if (sc != nullptr) {
GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "server");
}
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index a955ec2589..43788bfc5c 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -201,8 +201,8 @@ static void destruct_transport(grpc_exec_ctx* exec_ctx,
grpc_chttp2_goaway_parser_destroy(&t->goaway_parser);
for (i = 0; i < STREAM_LIST_COUNT; i++) {
- GPR_ASSERT(t->lists[i].head == NULL);
- GPR_ASSERT(t->lists[i].tail == NULL);
+ GPR_ASSERT(t->lists[i].head == nullptr);
+ GPR_ASSERT(t->lists[i].tail == nullptr);
}
GRPC_ERROR_UNREF(t->goaway_error);
@@ -575,7 +575,7 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
schedule_bdp_ping_locked(exec_ctx, t);
grpc_chttp2_act_on_flowctl_action(
- exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, NULL);
+ exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, nullptr);
}
grpc_chttp2_initiate_write(exec_ctx, t,
@@ -614,7 +614,7 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
GRPC_STATUS_UNAVAILABLE);
}
if (t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE) {
- if (t->close_transport_on_writes_finished == NULL) {
+ if (t->close_transport_on_writes_finished == nullptr) {
t->close_transport_on_writes_finished =
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Delayed close due to in-progress write");
@@ -729,7 +729,7 @@ static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
GPR_ASSERT((s->write_closed && s->read_closed) || s->id == 0);
if (s->id != 0) {
- GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) == NULL);
+ GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) == nullptr);
}
grpc_slice_buffer_destroy_internal(exec_ctx,
@@ -749,12 +749,12 @@ static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
}
}
- GPR_ASSERT(s->send_initial_metadata_finished == NULL);
- GPR_ASSERT(s->fetching_send_message == NULL);
- GPR_ASSERT(s->send_trailing_metadata_finished == NULL);
- GPR_ASSERT(s->recv_initial_metadata_ready == NULL);
- GPR_ASSERT(s->recv_message_ready == NULL);
- GPR_ASSERT(s->recv_trailing_metadata_finished == NULL);
+ GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
+ GPR_ASSERT(s->fetching_send_message == nullptr);
+ GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
+ GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
+ GPR_ASSERT(s->recv_message_ready == nullptr);
+ GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
grpc_chttp2_data_parser_destroy(exec_ctx, &s->data_parser);
grpc_chttp2_incoming_metadata_buffer_destroy(exec_ctx,
&s->metadata_buffer[0]);
@@ -781,13 +781,13 @@ static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
- if (s->stream_compression_ctx != NULL) {
+ if (s->stream_compression_ctx != nullptr) {
grpc_stream_compression_context_destroy(s->stream_compression_ctx);
- s->stream_compression_ctx = NULL;
+ s->stream_compression_ctx = nullptr;
}
- if (s->stream_decompression_ctx != NULL) {
+ if (s->stream_decompression_ctx != nullptr) {
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
s->destroy_stream_arg = then_schedule_closure;
@@ -807,16 +807,16 @@ grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t,
uint32_t id) {
- if (t->channel_callback.accept_stream == NULL) {
- return NULL;
+ if (t->channel_callback.accept_stream == nullptr) {
+ return nullptr;
}
grpc_chttp2_stream* accepting;
- GPR_ASSERT(t->accepting_stream == NULL);
+ GPR_ASSERT(t->accepting_stream == nullptr);
t->accepting_stream = &accepting;
t->channel_callback.accept_stream(exec_ctx,
t->channel_callback.accept_stream_user_data,
&t->base, (void*)(uintptr_t)id);
- t->accepting_stream = NULL;
+ t->accepting_stream = nullptr;
return accepting;
}
@@ -845,9 +845,9 @@ static void set_write_state(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
t->write_state = st;
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &t->run_after_write);
- if (t->close_transport_on_writes_finished != NULL) {
+ if (t->close_transport_on_writes_finished != nullptr) {
grpc_error* err = t->close_transport_on_writes_finished;
- t->close_transport_on_writes_finished = NULL;
+ t->close_transport_on_writes_finished = nullptr;
close_transport_locked(exec_ctx, t, err);
}
}
@@ -987,7 +987,7 @@ static grpc_closure_scheduler* write_scheduler(grpc_chttp2_transport* t,
case GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY:
return grpc_schedule_on_exec_ctx;
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
#define WRITE_STATE_TUPLE_TO_INT(p, i) (2 * (int)(p) + (int)(i))
@@ -1221,7 +1221,7 @@ static grpc_closure* add_closure_barrier(grpc_closure* closure) {
static void null_then_run_closure(grpc_exec_ctx* exec_ctx,
grpc_closure** closure, grpc_error* error) {
grpc_closure* c = *closure;
- *closure = NULL;
+ *closure = nullptr;
GRPC_CLOSURE_RUN(exec_ctx, c, error);
}
@@ -1231,8 +1231,8 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
grpc_closure** pclosure,
grpc_error* error, const char* desc) {
grpc_closure* closure = *pclosure;
- *pclosure = NULL;
- if (closure == NULL) {
+ *pclosure = nullptr;
+ if (closure == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
@@ -1262,7 +1262,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
if (closure->next_data.scratch < CLOSURE_BARRIER_FIRST_REF_BIT) {
if (closure->next_data.scratch & CLOSURE_BARRIER_STATS_BIT) {
grpc_transport_move_stats(&s->stats, s->collecting_stats);
- s->collecting_stats = NULL;
+ s->collecting_stats = nullptr;
}
if ((t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE) ||
!(closure->next_data.scratch & CLOSURE_BARRIER_MAY_COVER_WRITE)) {
@@ -1275,7 +1275,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
}
static bool contains_non_ok_status(grpc_metadata_batch* batch) {
- if (batch->idx.named.grpc_status != NULL) {
+ if (batch->idx.named.grpc_status != nullptr) {
return !grpc_mdelem_eq(batch->idx.named.grpc_status->md,
GRPC_MDELEM_GRPC_STATUS_0);
}
@@ -1306,7 +1306,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
for (;;) {
- if (s->fetching_send_message == NULL) {
+ if (s->fetching_send_message == nullptr) {
/* Stream was cancelled before message fetch completed */
abort(); /* TODO(ctiller): what cleanup here? */
return; /* early out */
@@ -1320,14 +1320,14 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
"fetching_send_message_finished");
} else {
grpc_chttp2_write_cb* cb = t->write_cb_pool;
- if (cb == NULL) {
+ if (cb == nullptr) {
cb = (grpc_chttp2_write_cb*)gpr_malloc(sizeof(*cb));
} else {
t->write_cb_pool = cb->next;
}
cb->call_at_byte = notify_offset;
cb->closure = s->fetching_send_message_finished;
- s->fetching_send_message_finished = NULL;
+ s->fetching_send_message_finished = nullptr;
grpc_chttp2_write_cb** list =
s->fetching_send_message->flags & GRPC_WRITE_THROUGH
? &s->on_write_finished_cbs
@@ -1335,7 +1335,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
cb->next = *list;
*list = cb;
}
- s->fetching_send_message = NULL;
+ s->fetching_send_message = nullptr;
return; /* early out */
} else if (grpc_byte_stream_next(exec_ctx, s->fetching_send_message,
UINT32_MAX, &s->complete_fetch_locked)) {
@@ -1373,7 +1373,7 @@ static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id,
bool is_client, bool is_initial) {
- for (grpc_linked_mdelem* md = md_batch->list.head; md != NULL;
+ for (grpc_linked_mdelem* md = md_batch->list.head; md != nullptr;
md = md->next) {
char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
@@ -1412,9 +1412,9 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
grpc_closure* on_complete = op->on_complete;
- if (on_complete == NULL) {
+ if (on_complete == nullptr) {
on_complete =
- GRPC_CLOSURE_CREATE(do_nothing, NULL, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_CREATE(do_nothing, nullptr, grpc_schedule_on_exec_ctx);
}
/* use final_data as a barrier until enqueue time; the inital counter is
@@ -1423,7 +1423,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
on_complete->error_data.error = GRPC_ERROR_NONE;
if (op->collect_stats) {
- GPR_ASSERT(s->collecting_stats == NULL);
+ GPR_ASSERT(s->collecting_stats == nullptr);
s->collecting_stats = op_payload->collect_stats.collect_stats;
on_complete->next_data.scratch |= CLOSURE_BARRIER_STATS_BIT;
}
@@ -1436,12 +1436,12 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->send_initial_metadata) {
GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx);
- GPR_ASSERT(s->send_initial_metadata_finished == NULL);
+ GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
/* Identify stream compression */
if (op_payload->send_initial_metadata.send_initial_metadata->idx.named
- .content_encoding == NULL ||
+ .content_encoding == nullptr ||
grpc_stream_compression_method_parse(
GRPC_MDVALUE(
op_payload->send_initial_metadata.send_initial_metadata->idx
@@ -1502,7 +1502,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
}
} else {
- s->send_initial_metadata = NULL;
+ s->send_initial_metadata = nullptr;
grpc_chttp2_complete_closure_step(
exec_ctx, t, s, &s->send_initial_metadata_finished,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@@ -1511,7 +1511,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
"send_initial_metadata_finished");
}
}
- if (op_payload->send_initial_metadata.peer_string != NULL) {
+ if (op_payload->send_initial_metadata.peer_string != nullptr) {
gpr_atm_rel_store(op_payload->send_initial_metadata.peer_string,
(gpr_atm)gpr_strdup(t->peer_string));
}
@@ -1538,7 +1538,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
&s->write_closed_error, 1),
"fetching_send_message_finished");
} else {
- GPR_ASSERT(s->fetching_send_message == NULL);
+ GPR_ASSERT(s->fetching_send_message == nullptr);
uint8_t* frame_hdr = grpc_slice_buffer_tiny_add(
&s->flow_controlled_buffer, GRPC_HEADER_SIZE_IN_BYTES);
uint32_t flags = op_payload->send_message.send_message->flags;
@@ -1566,7 +1566,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->send_trailing_metadata) {
GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx);
- GPR_ASSERT(s->send_trailing_metadata_finished == NULL);
+ GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->send_trailing_metadata_finished = add_closure_barrier(on_complete);
s->send_trailing_metadata =
@@ -1594,7 +1594,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
s->seen_error = true;
}
if (s->write_closed) {
- s->send_trailing_metadata = NULL;
+ s->send_trailing_metadata = nullptr;
grpc_chttp2_complete_closure_step(
exec_ctx, t, s, &s->send_trailing_metadata_finished,
grpc_metadata_batch_is_empty(
@@ -1616,14 +1616,14 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->recv_initial_metadata) {
GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx);
- GPR_ASSERT(s->recv_initial_metadata_ready == NULL);
+ GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
s->recv_initial_metadata_ready =
op_payload->recv_initial_metadata.recv_initial_metadata_ready;
s->recv_initial_metadata =
op_payload->recv_initial_metadata.recv_initial_metadata;
s->trailing_metadata_available =
op_payload->recv_initial_metadata.trailing_metadata_available;
- if (op_payload->recv_initial_metadata.peer_string != NULL) {
+ if (op_payload->recv_initial_metadata.peer_string != nullptr) {
gpr_atm_rel_store(op_payload->recv_initial_metadata.peer_string,
(gpr_atm)gpr_strdup(t->peer_string));
}
@@ -1633,7 +1633,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->recv_message) {
GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx);
size_t already_received;
- GPR_ASSERT(s->recv_message_ready == NULL);
+ GPR_ASSERT(s->recv_message_ready == nullptr);
GPR_ASSERT(!s->pending_byte_stream);
s->recv_message_ready = op_payload->recv_message.recv_message_ready;
s->recv_message = op_payload->recv_message.recv_message;
@@ -1651,7 +1651,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->recv_trailing_metadata) {
GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx);
- GPR_ASSERT(s->recv_trailing_metadata_finished == NULL);
+ GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
s->recv_trailing_metadata_finished = add_closure_barrier(on_complete);
s->recv_trailing_metadata =
op_payload->recv_trailing_metadata.recv_trailing_metadata;
@@ -1761,8 +1761,8 @@ static void send_goaway(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
grpc_http2_error_code http_error;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, NULL, &slice,
- &http_error);
+ grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, nullptr,
+ &slice, &http_error);
grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error,
grpc_slice_ref_internal(slice), &t->qbuf);
grpc_chttp2_initiate_write(exec_ctx, t,
@@ -1815,12 +1815,12 @@ static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
}
if (op->send_ping) {
- send_ping_locked(exec_ctx, t, NULL, op->send_ping);
+ send_ping_locked(exec_ctx, t, nullptr, op->send_ping);
grpc_chttp2_initiate_write(exec_ctx, t,
GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING);
}
- if (op->on_connectivity_state_change != NULL) {
+ if (op->on_connectivity_state_change != nullptr) {
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &t->channel_callback.state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
@@ -1856,7 +1856,7 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
- if (s->recv_initial_metadata_ready != NULL &&
+ if (s->recv_initial_metadata_ready != nullptr &&
s->published_metadata[0] != GRPC_METADATA_NOT_PUBLISHED) {
if (s->seen_error) {
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
@@ -1876,8 +1876,8 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
grpc_error* error = GRPC_ERROR_NONE;
- if (s->recv_message_ready != NULL) {
- *s->recv_message = NULL;
+ if (s->recv_message_ready != nullptr) {
+ *s->recv_message = nullptr;
if (s->final_metadata_requested && s->seen_error) {
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
if (!s->pending_byte_stream) {
@@ -1906,7 +1906,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
if (!grpc_stream_decompress(
s->stream_decompression_ctx,
&s->unprocessed_incoming_frames_buffer,
- &s->decompressed_data_buffer, NULL,
+ &s->decompressed_data_buffer, nullptr,
GRPC_HEADER_SIZE_IN_BYTES - s->decompressed_header_bytes,
&end_of_context)) {
grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
@@ -1922,17 +1922,17 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
}
error = grpc_deframe_unprocessed_incoming_frames(
exec_ctx, &s->data_parser, s, &s->decompressed_data_buffer,
- NULL, s->recv_message);
+ nullptr, s->recv_message);
if (end_of_context) {
grpc_stream_compression_context_destroy(
s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
}
} else {
error = grpc_deframe_unprocessed_incoming_frames(
exec_ctx, &s->data_parser, s,
- &s->unprocessed_incoming_frames_buffer, NULL, s->recv_message);
+ &s->unprocessed_incoming_frames_buffer, nullptr, s->recv_message);
}
if (error != GRPC_ERROR_NONE) {
s->seen_error = true;
@@ -1941,15 +1941,15 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
grpc_slice_buffer_reset_and_unref_internal(
exec_ctx, &s->unprocessed_incoming_frames_buffer);
break;
- } else if (*s->recv_message != NULL) {
+ } else if (*s->recv_message != nullptr) {
break;
}
}
}
- if (error == GRPC_ERROR_NONE && *s->recv_message != NULL) {
+ if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) {
null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
} else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) {
- *s->recv_message = NULL;
+ *s->recv_message = nullptr;
null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
}
GRPC_ERROR_UNREF(error);
@@ -1960,7 +1960,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
- if (s->recv_trailing_metadata_finished != NULL && s->read_closed &&
+ if (s->recv_trailing_metadata_finished != nullptr && s->read_closed &&
s->write_closed) {
if (s->seen_error) {
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
@@ -1972,7 +1972,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
bool pending_data = s->pending_byte_stream ||
s->unprocessed_incoming_frames_buffer.length > 0;
if (s->read_closed && s->frame_storage.length > 0 && !pending_data &&
- !s->seen_error && s->recv_trailing_metadata_finished != NULL) {
+ !s->seen_error && s->recv_trailing_metadata_finished != nullptr) {
/* Maybe some SYNC_FLUSH data is left in frame_storage. Consume them and
* maybe decompress the next 5 bytes in the stream. */
bool end_of_context;
@@ -1980,10 +1980,10 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
s->stream_decompression_ctx = grpc_stream_compression_context_create(
s->stream_decompression_method);
}
- if (!grpc_stream_decompress(s->stream_decompression_ctx,
- &s->frame_storage,
- &s->unprocessed_incoming_frames_buffer, NULL,
- GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) {
+ if (!grpc_stream_decompress(
+ s->stream_decompression_ctx, &s->frame_storage,
+ &s->unprocessed_incoming_frames_buffer, nullptr,
+ GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) {
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
exec_ctx, &s->unprocessed_incoming_frames_buffer);
@@ -1995,12 +1995,12 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
}
if (end_of_context) {
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
}
}
if (s->read_closed && s->frame_storage.length == 0 && !pending_data &&
- s->recv_trailing_metadata_finished != NULL) {
+ s->recv_trailing_metadata_finished != nullptr) {
grpc_chttp2_incoming_metadata_buffer_publish(
exec_ctx, &s->metadata_buffer[1], s->recv_trailing_metadata);
grpc_chttp2_complete_closure_step(
@@ -2016,18 +2016,18 @@ static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
(grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
GPR_ASSERT(s);
if (t->incoming_stream == s) {
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
}
if (s->pending_byte_stream) {
- if (s->on_next != NULL) {
+ if (s->on_next != nullptr) {
grpc_chttp2_incoming_byte_stream* bs = s->data_parser.parsing_frame;
if (error == GRPC_ERROR_NONE) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
}
incoming_byte_stream_publish_error(exec_ctx, bs, error);
incoming_byte_stream_unref(exec_ctx, bs);
- s->data_parser.parsing_frame = NULL;
+ s->data_parser.parsing_frame = nullptr;
} else {
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_REF(error);
@@ -2064,8 +2064,8 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
if (!s->read_closed || !s->write_closed) {
if (s->id != 0) {
grpc_http2_error_code http_error;
- grpc_error_get_status(exec_ctx, due_to_error, s->deadline, NULL, NULL,
- &http_error);
+ grpc_error_get_status(exec_ctx, due_to_error, s->deadline, nullptr,
+ nullptr, &http_error);
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error,
&s->stats.outgoing));
@@ -2083,7 +2083,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_chttp2_stream* s, grpc_error* error) {
grpc_status_code status;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, NULL);
+ grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, nullptr);
if (status != GRPC_STATUS_OK) {
s->seen_error = true;
}
@@ -2094,7 +2094,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
what we want - which is safe because we haven't told anyone
about the metadata yet */
if (s->published_metadata[1] == GRPC_METADATA_NOT_PUBLISHED ||
- s->recv_trailing_metadata_finished != NULL) {
+ s->recv_trailing_metadata_finished != nullptr) {
char status_string[GPR_LTOA_MIN_BUFSIZE];
gpr_ltoa(status, status_string);
GRPC_LOG_IF_ERROR("add_status",
@@ -2165,17 +2165,17 @@ void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* s, grpc_error* error) {
error =
removal_error(error, s, "Pending writes failed due to stream closure");
- s->send_initial_metadata = NULL;
+ s->send_initial_metadata = nullptr;
grpc_chttp2_complete_closure_step(
exec_ctx, t, s, &s->send_initial_metadata_finished, GRPC_ERROR_REF(error),
"send_initial_metadata_finished");
- s->send_trailing_metadata = NULL;
+ s->send_trailing_metadata = nullptr;
grpc_chttp2_complete_closure_step(
exec_ctx, t, s, &s->send_trailing_metadata_finished,
GRPC_ERROR_REF(error), "send_trailing_metadata_finished");
- s->fetching_send_message = NULL;
+ s->fetching_send_message = nullptr;
grpc_chttp2_complete_closure_step(
exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_REF(error),
"fetching_send_message_finished");
@@ -2248,7 +2248,7 @@ static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_status_code grpc_status;
grpc_slice slice;
grpc_error_get_status(exec_ctx, error, s->deadline, &grpc_status, &slice,
- NULL);
+ nullptr);
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100);
@@ -2472,7 +2472,7 @@ static grpc_error* try_http_parsing(grpc_exec_ctx* exec_ctx,
grpc_error* parse_error = GRPC_ERROR_NONE;
for (; i < t->read_buffer.count && parse_error == GRPC_ERROR_NONE; i++) {
parse_error =
- grpc_http_parser_parse(&parser, t->read_buffer.slices[i], NULL);
+ grpc_http_parser_parse(&parser, t->read_buffer.slices[i], nullptr);
}
if (parse_error == GRPC_ERROR_NONE &&
(parse_error = grpc_http_parser_eof(&parser)) == GRPC_ERROR_NONE) {
@@ -2569,7 +2569,7 @@ static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
&t->read_action_locked);
grpc_chttp2_act_on_flowctl_action(exec_ctx, t->flow_control->MakeAction(),
- t, NULL);
+ t, nullptr);
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
} else {
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action");
@@ -2820,7 +2820,7 @@ static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
} else {
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
- s->on_next = NULL;
+ s->on_next = nullptr;
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_NONE;
grpc_chttp2_cancel_stream(exec_ctx, s->t, s, GRPC_ERROR_REF(error));
@@ -2859,9 +2859,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
} else if (s->byte_stream_error != GRPC_ERROR_NONE) {
GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
- if (s->data_parser.parsing_frame != NULL) {
+ if (s->data_parser.parsing_frame != nullptr) {
incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
- s->data_parser.parsing_frame = NULL;
+ s->data_parser.parsing_frame = nullptr;
}
} else if (s->read_closed) {
if (bs->remaining_bytes != 0) {
@@ -2869,9 +2869,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
- if (s->data_parser.parsing_frame != NULL) {
+ if (s->data_parser.parsing_frame != nullptr) {
incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
- s->data_parser.parsing_frame = NULL;
+ s->data_parser.parsing_frame = nullptr;
}
} else {
/* Should never reach here. */
@@ -2927,7 +2927,7 @@ static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
}
if (!grpc_stream_decompress(s->stream_decompression_ctx,
&s->unprocessed_incoming_frames_buffer,
- &s->decompressed_data_buffer, NULL,
+ &s->decompressed_data_buffer, nullptr,
MAX_SIZE_T, &end_of_context)) {
error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream decompression error.");
@@ -2939,7 +2939,7 @@ static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
s->unprocessed_incoming_frames_decompressed = true;
if (end_of_context) {
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
if (s->unprocessed_incoming_frames_buffer.length == 0) {
*slice = grpc_empty_slice();
@@ -2947,7 +2947,7 @@ static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
}
error = grpc_deframe_unprocessed_incoming_frames(
exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer,
- slice, NULL);
+ slice, nullptr);
if (error != GRPC_ERROR_NONE) {
return error;
}
@@ -2985,7 +2985,7 @@ static void incoming_byte_stream_publish_error(
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
- s->on_next = NULL;
+ s->on_next = nullptr;
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_REF(error);
grpc_chttp2_cancel_stream(exec_ctx, bs->transport, bs->stream,
@@ -3006,7 +3006,7 @@ grpc_error* grpc_chttp2_incoming_byte_stream_push(
return error;
} else {
bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice);
- if (slice_out != NULL) {
+ if (slice_out != nullptr) {
*slice_out = slice;
}
return GRPC_ERROR_NONE;
@@ -3248,7 +3248,7 @@ void grpc_chttp2_transport_start_reading(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t = (grpc_chttp2_transport*)transport;
GRPC_CHTTP2_REF_TRANSPORT(
t, "reading_action"); /* matches unref inside reading_action */
- if (read_buffer != NULL) {
+ if (read_buffer != nullptr) {
grpc_slice_buffer_move_into(read_buffer, &t->read_buffer);
gpr_free(read_buffer);
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc
index 7d2c7f5ab9..f0c3b55792 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_data.cc
@@ -32,13 +32,13 @@
grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser) {
parser->state = GRPC_CHTTP2_DATA_FH_0;
- parser->parsing_frame = NULL;
+ parser->parsing_frame = nullptr;
return GRPC_ERROR_NONE;
}
void grpc_chttp2_data_parser_destroy(grpc_exec_ctx* exec_ctx,
grpc_chttp2_data_parser* parser) {
- if (parser->parsing_frame != NULL) {
+ if (parser->parsing_frame != nullptr) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
exec_ctx, parser->parsing_frame,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Parser destroyed"), false));
@@ -105,9 +105,9 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_chttp2_transport* t = s->t;
while (slices->count > 0) {
- uint8_t* beg = NULL;
- uint8_t* end = NULL;
- uint8_t* cur = NULL;
+ uint8_t* beg = nullptr;
+ uint8_t* end = nullptr;
+ uint8_t* cur = nullptr;
grpc_slice slice = grpc_slice_buffer_take_first(slices);
@@ -188,8 +188,8 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_4:
s->stats.incoming.framing_bytes++;
- GPR_ASSERT(stream_out != NULL);
- GPR_ASSERT(p->parsing_frame == NULL);
+ GPR_ASSERT(stream_out != nullptr);
+ GPR_ASSERT(p->parsing_frame == nullptr);
p->frame_size |= ((uint32_t)*cur);
p->state = GRPC_CHTTP2_DATA_FRAME;
++cur;
@@ -203,7 +203,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
if (p->parsing_frame->remaining_bytes == 0) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true));
- p->parsing_frame = NULL;
+ p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
}
s->pending_byte_stream = true;
@@ -216,8 +216,8 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_unref_internal(exec_ctx, slice);
return GRPC_ERROR_NONE;
case GRPC_CHTTP2_DATA_FRAME: {
- GPR_ASSERT(p->parsing_frame != NULL);
- GPR_ASSERT(slice_out != NULL);
+ GPR_ASSERT(p->parsing_frame != nullptr);
+ GPR_ASSERT(slice_out != nullptr);
if (cur == end) {
grpc_slice_unref_internal(exec_ctx, slice);
continue;
@@ -239,7 +239,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_unref_internal(exec_ctx, slice);
return error;
}
- p->parsing_frame = NULL;
+ p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
grpc_slice_unref_internal(exec_ctx, slice);
return GRPC_ERROR_NONE;
@@ -273,7 +273,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_unref_internal(exec_ctx, slice);
return error;
}
- p->parsing_frame = NULL;
+ p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
cur += p->frame_size;
grpc_slice_buffer_undo_take_first(
@@ -302,7 +302,7 @@ grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
grpc_slice_ref_internal(slice);
grpc_slice_buffer_add(&s->unprocessed_incoming_frames_buffer, slice);
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_NONE);
- s->on_next = NULL;
+ s->on_next = nullptr;
s->unprocessed_incoming_frames_decompressed = false;
} else {
grpc_slice_ref_internal(slice);
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
index 6be1d0e0f0..a2ce709a2e 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
@@ -26,7 +26,7 @@
#include <grpc/support/string_util.h>
void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p) {
- p->debug_data = NULL;
+ p->debug_data = nullptr;
}
void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p) {
@@ -137,7 +137,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_chttp2_add_incoming_goaway(
exec_ctx, t, (uint32_t)p->error_code,
grpc_slice_new(p->debug_data, p->debug_length, gpr_free));
- p->debug_data = NULL;
+ p->debug_data = nullptr;
}
return GRPC_ERROR_NONE;
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.cc b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
index 62a4587ac6..08407a8e67 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
@@ -79,7 +79,7 @@ grpc_error* grpc_chttp2_window_update_parser_parse(
p->byte++;
}
- if (s != NULL) {
+ if (s != nullptr) {
s->stats.incoming.framing_bytes += (uint32_t)(end - cur);
}
@@ -95,7 +95,7 @@ grpc_error* grpc_chttp2_window_update_parser_parse(
GPR_ASSERT(is_last);
if (t->incoming_stream_id != 0) {
- if (s != NULL) {
+ if (s != nullptr) {
s->flow_control->RecvUpdate(received_update);
if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) {
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index 3636440905..e6e4ff24a3 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -51,10 +51,10 @@
/* don't consider adding anything bigger than this to the hpack table */
#define MAX_DECODER_SPACE_USAGE 512
-static grpc_slice_refcount terminal_slice_refcount = {NULL, NULL};
+static grpc_slice_refcount terminal_slice_refcount = {nullptr, nullptr};
static const grpc_slice terminal_slice = {
&terminal_slice_refcount, /* refcount */
- {{0, 0}} /* data.refcounted */
+ {{nullptr, 0}} /* data.refcounted */
};
extern "C" grpc_tracer_flag grpc_http_trace;
@@ -477,7 +477,7 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
if (GRPC_TRACER_ON(grpc_http_trace)) {
char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
- char* v = NULL;
+ char* v = nullptr;
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX);
} else {
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
index 1181402918..960610eee0 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
@@ -653,7 +653,7 @@ static grpc_error* on_hdr(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p,
grpc_mdelem md, int add_to_table) {
if (GRPC_TRACER_ON(grpc_http_trace)) {
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char* v = NULL;
+ char* v = nullptr;
if (grpc_is_binary_header(GRPC_MDKEY(md))) {
v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
} else {
@@ -674,7 +674,7 @@ static grpc_error* on_hdr(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p,
grpc_error* err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
if (err != GRPC_ERROR_NONE) return err;
}
- if (p->on_header == NULL) {
+ if (p->on_header == nullptr) {
GRPC_MDELEM_UNREF(exec_ctx, md);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set");
}
@@ -1523,7 +1523,7 @@ static grpc_error* begin_parse_string(grpc_exec_ctx* exec_ctx,
uint8_t binary,
grpc_chttp2_hpack_parser_string* str) {
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
- p->current_slice_refcount != NULL) {
+ p->current_slice_refcount != nullptr) {
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
str->copied = false;
str->data.referenced.refcount = p->current_slice_refcount;
@@ -1613,15 +1613,15 @@ static grpc_error* parse_value_string_with_literal_key(
void grpc_chttp2_hpack_parser_init(grpc_exec_ctx* exec_ctx,
grpc_chttp2_hpack_parser* p) {
- p->on_header = NULL;
- p->on_header_user_data = NULL;
+ p->on_header = nullptr;
+ p->on_header_user_data = nullptr;
p->state = parse_begin;
p->key.data.referenced = grpc_empty_slice();
- p->key.data.copied.str = NULL;
+ p->key.data.copied.str = nullptr;
p->key.data.copied.capacity = 0;
p->key.data.copied.length = 0;
p->value.data.referenced = grpc_empty_slice();
- p->value.data.copied.str = NULL;
+ p->value.data.copied.str = nullptr;
p->value.data.copied.capacity = 0;
p->value.data.copied.length = 0;
p->dynamic_table_update_allowed = 2;
@@ -1659,7 +1659,7 @@ grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
error = p->state(exec_ctx, p, start, target);
start = target;
}
- p->current_slice_refcount = NULL;
+ p->current_slice_refcount = nullptr;
return error;
}
@@ -1689,7 +1689,7 @@ static void parse_stream_compression_md(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_metadata_batch* initial_metadata) {
- if (initial_metadata->idx.named.content_encoding == NULL ||
+ if (initial_metadata->idx.named.content_encoding == nullptr ||
grpc_stream_compression_method_parse(
GRPC_MDVALUE(initial_metadata->idx.named.content_encoding->md), false,
&s->stream_decompression_method) == 0) {
@@ -1705,7 +1705,7 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_slice slice, int is_last) {
grpc_chttp2_hpack_parser* parser = (grpc_chttp2_hpack_parser*)hpack_parser;
GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0);
- if (s != NULL) {
+ if (s != nullptr) {
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
}
grpc_error* error = grpc_chttp2_hpack_parser_parse(exec_ctx, parser, slice);
@@ -1721,7 +1721,7 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
}
/* need to check for null stream: this can occur if we receive an invalid
stream id on a header */
- if (s != NULL) {
+ if (s != nullptr) {
if (parser->is_boundary) {
if (s->header_frames_received == GPR_ARRAY_SIZE(s->metadata_buffer)) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
@@ -1756,8 +1756,8 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_NONE);
}
}
- parser->on_header = NULL;
- parser->on_header_user_data = NULL;
+ parser->on_header = nullptr;
+ parser->on_header_user_data = nullptr;
parser->is_boundary = 0xde;
parser->is_eof = 0xde;
parser->dynamic_table_update_allowed = 2;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc
index 1a2bc9224e..7970d2ae27 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc
@@ -35,7 +35,7 @@ static struct {
const char* value;
} static_table[] = {
/* 0: */
- {NULL, NULL},
+ {nullptr, nullptr},
/* 1: */
{":authority", ""},
/* 2: */
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
index 15f80fb8a1..4461f8c12c 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
@@ -51,7 +51,7 @@ grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) {
- for (grpc_linked_mdelem* l = buffer->batch.list.head; l != NULL;
+ for (grpc_linked_mdelem* l = buffer->batch.list.head; l != nullptr;
l = l->next) {
if (grpc_slice_eq(GRPC_MDKEY(l->md), GRPC_MDKEY(elem))) {
GRPC_MDELEM_UNREF(exec_ctx, l->md);
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc
index 6737c26e72..5f07dec8e8 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.cc
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -191,7 +191,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
if (err != GRPC_ERROR_NONE) {
return err;
}
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_0;
return GRPC_ERROR_NONE;
@@ -225,7 +225,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
return err;
}
t->deframe_state = GRPC_DTS_FH_0;
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
return GRPC_ERROR_NONE;
} else if ((uint32_t)(end - cur) > t->incoming_frame_size) {
size_t cur_offset = (size_t)(cur - beg);
@@ -238,7 +238,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
return err;
}
cur += t->incoming_frame_size;
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
goto dts_fh_0; /* loop */
} else {
err =
@@ -252,10 +252,10 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
t->incoming_frame_size -= (uint32_t)(end - cur);
return GRPC_ERROR_NONE;
}
- GPR_UNREACHABLE_CODE(return 0);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
- GPR_UNREACHABLE_CODE(return 0);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
@@ -337,7 +337,7 @@ static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
t->parser = grpc_chttp2_header_parser_parse;
t->parser_data = &t->hpack_parser;
t->hpack_parser.on_header = skip_header;
- t->hpack_parser.on_header_user_data = NULL;
+ t->hpack_parser.on_header_user_data = nullptr;
t->hpack_parser.is_boundary = is_eoh;
t->hpack_parser.is_eof = (uint8_t)(is_eoh ? t->header_eof : 0);
} else {
@@ -369,7 +369,7 @@ static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
if (err != GRPC_ERROR_NONE) {
goto error_handler;
}
- if (s == NULL) {
+ if (s == nullptr) {
return init_skip_frame_parser(exec_ctx, t, 0);
}
s->received_bytes += t->incoming_frame_size;
@@ -391,9 +391,9 @@ error_handler:
t->ping_policy.max_pings_without_data;
t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST;
return GRPC_ERROR_NONE;
- } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
+ } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
/* handle stream errors by closing the stream */
- if (s != NULL) {
+ if (s != nullptr) {
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, err);
}
grpc_slice_buffer_add(
@@ -415,7 +415,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
GPR_TIMER_BEGIN("on_initial_header", 0);
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
if (GRPC_TRACER_ON(grpc_http_trace)) {
char* key = grpc_slice_to_c_string(GRPC_MDKEY(md));
@@ -437,7 +437,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
grpc_millis* cached_timeout =
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
grpc_millis timeout;
- if (cached_timeout != NULL) {
+ if (cached_timeout != nullptr) {
timeout = *cached_timeout;
} else {
if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
@@ -499,7 +499,7 @@ static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp,
GPR_TIMER_BEGIN("on_trailing_header", 0);
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
if (GRPC_TRACER_ON(grpc_http_trace)) {
char* key = grpc_slice_to_c_string(GRPC_MDKEY(md));
@@ -575,7 +575,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
/* could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream */
s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- if (s == NULL) {
+ if (s == nullptr) {
if (is_continuation) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR,
@@ -617,7 +617,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
t->last_new_stream_id = t->incoming_stream_id;
s = t->incoming_stream =
grpc_chttp2_parsing_accept_stream(exec_ctx, t, t->incoming_stream_id);
- if (s == NULL) {
+ if (s == nullptr) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted"));
return init_skip_frame_parser(exec_ctx, t, 1);
@@ -625,12 +625,12 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
} else {
t->incoming_stream = s;
}
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
s->stats.incoming.framing_bytes += 9;
if (s->read_closed) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "skipping already closed grpc_chttp2_stream header"));
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
return init_skip_frame_parser(exec_ctx, t, 1);
}
t->parser = grpc_chttp2_header_parser_parse;
@@ -639,7 +639,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
case 0:
if (t->is_client && t->header_eof) {
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing Trailers-Only"));
- if (s->trailing_metadata_available != NULL) {
+ if (s->trailing_metadata_available != nullptr) {
*s->trailing_metadata_available = true;
}
t->hpack_parser.on_header = on_trailing_header;
@@ -677,7 +677,7 @@ static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
if (t->incoming_stream_id != 0) {
grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- if (s == NULL) {
+ if (s == nullptr) {
return init_skip_frame_parser(exec_ctx, t, 0);
}
s->stats.incoming.framing_bytes += 9;
@@ -757,7 +757,7 @@ static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
grpc_error* err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last);
if (err == GRPC_ERROR_NONE) {
return err;
- } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
+ } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
if (GRPC_TRACER_ON(grpc_http_trace)) {
const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc
index 8d25ab277d..d92527f05c 100644
--- a/src/core/ext/transport/chttp2/transport/stream_lists.cc
+++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc
@@ -46,7 +46,7 @@ grpc_tracer_flag grpc_trace_http2_stream_state =
static bool stream_list_empty(grpc_chttp2_transport* t,
grpc_chttp2_stream_list_id id) {
- return t->lists[id].head == NULL;
+ return t->lists[id].head == nullptr;
}
static bool stream_list_pop(grpc_chttp2_transport* t,
@@ -58,10 +58,10 @@ static bool stream_list_pop(grpc_chttp2_transport* t,
GPR_ASSERT(s->included[id]);
if (new_head) {
t->lists[id].head = new_head;
- new_head->links[id].prev = NULL;
+ new_head->links[id].prev = nullptr;
} else {
- t->lists[id].head = NULL;
- t->lists[id].tail = NULL;
+ t->lists[id].head = nullptr;
+ t->lists[id].tail = nullptr;
}
s->included[id] = 0;
}
@@ -70,7 +70,7 @@ static bool stream_list_pop(grpc_chttp2_transport* t,
gpr_log(GPR_DEBUG, "%p[%d][%s]: pop from %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}
- return s != 0;
+ return s != nullptr;
}
static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
@@ -111,7 +111,7 @@ static void stream_list_add_tail(grpc_chttp2_transport* t,
grpc_chttp2_stream* old_tail;
GPR_ASSERT(!s->included[id]);
old_tail = t->lists[id].tail;
- s->links[id].next = NULL;
+ s->links[id].next = nullptr;
s->links[id].prev = old_tail;
if (old_tail) {
old_tail->links[id].next = s;
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.cc b/src/core/ext/transport/chttp2/transport/stream_map.cc
index c863191795..e4f08f5a6c 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.cc
+++ b/src/core/ext/transport/chttp2/transport/stream_map.cc
@@ -62,7 +62,7 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key,
GPR_ASSERT(count == 0 || keys[count - 1] < key);
GPR_ASSERT(value);
- GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == NULL);
+ GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr);
if (count == capacity) {
if (map->free > capacity / 4) {
@@ -92,7 +92,7 @@ static void** find(grpc_chttp2_stream_map* map, uint32_t key) {
void** values = map->values;
uint32_t mid_key;
- if (max_idx == 0) return NULL;
+ if (max_idx == 0) return nullptr;
while (min_idx < max_idx) {
/* find the midpoint, avoiding overflow */
@@ -109,29 +109,29 @@ static void** find(grpc_chttp2_stream_map* map, uint32_t key) {
}
}
- return NULL;
+ return nullptr;
}
void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key) {
void** pvalue = find(map, key);
- void* out = NULL;
- if (pvalue != NULL) {
+ void* out = nullptr;
+ if (pvalue != nullptr) {
out = *pvalue;
- *pvalue = NULL;
- map->free += (out != NULL);
+ *pvalue = nullptr;
+ map->free += (out != nullptr);
/* recognize complete emptyness and ensure we can skip
* defragmentation later */
if (map->free == map->count) {
map->free = map->count = 0;
}
- GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == NULL);
+ GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr);
}
return out;
}
void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key) {
void** pvalue = find(map, key);
- return pvalue != NULL ? *pvalue : NULL;
+ return pvalue != nullptr ? *pvalue : nullptr;
}
size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map) {
@@ -140,11 +140,12 @@ size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map) {
void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map) {
if (map->count == map->free) {
- return NULL;
+ return nullptr;
}
if (map->free != 0) {
map->count = compact(map->keys, map->values, map->count);
map->free = 0;
+ GPR_ASSERT(map->count > 0);
}
return map->values[((size_t)rand()) % map->count];
}
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
index 6154bdb682..61a2598618 100644
--- a/src/core/ext/transport/chttp2/transport/writing.cc
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -120,7 +120,7 @@ static bool update_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_error* error) {
bool sched_any = false;
grpc_chttp2_write_cb* cb = *list;
- *list = NULL;
+ *list = nullptr;
*ctr += send_bytes;
while (cb) {
grpc_chttp2_write_cb* next = cb->next;
@@ -330,24 +330,25 @@ class DataSendContext {
bool is_last_data_frame =
(send_bytes == s_->compressed_data_buffer.length &&
s_->flow_controlled_buffer.length == 0 &&
- s_->fetching_send_message == NULL);
- if (is_last_data_frame && s_->send_trailing_metadata != NULL &&
- s_->stream_compression_ctx != NULL) {
- if (!grpc_stream_compress(s_->stream_compression_ctx,
- &s_->flow_controlled_buffer,
- &s_->compressed_data_buffer, NULL, MAX_SIZE_T,
- GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) {
+ s_->fetching_send_message == nullptr);
+ if (is_last_data_frame && s_->send_trailing_metadata != nullptr &&
+ s_->stream_compression_ctx != nullptr) {
+ if (!grpc_stream_compress(
+ s_->stream_compression_ctx, &s_->flow_controlled_buffer,
+ &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
+ GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) {
gpr_log(GPR_ERROR, "Stream compression failed.");
}
grpc_stream_compression_context_destroy(s_->stream_compression_ctx);
- s_->stream_compression_ctx = NULL;
+ s_->stream_compression_ctx = nullptr;
/* After finish, bytes in s->compressed_data_buffer may be
* more than max_outgoing. Start another round of the current
* while loop so that send_bytes and is_last_data_frame are
* recalculated. */
return;
}
- is_last_frame_ = is_last_data_frame && s_->send_trailing_metadata != NULL &&
+ is_last_frame_ = is_last_data_frame &&
+ s_->send_trailing_metadata != nullptr &&
grpc_metadata_batch_is_empty(s_->send_trailing_metadata);
grpc_chttp2_encode_data(s_->id, &s_->compressed_data_buffer, send_bytes,
is_last_frame_, &s_->stats.outgoing, &t_->outbuf);
@@ -358,14 +359,14 @@ class DataSendContext {
}
void CompressMoreBytes() {
- if (s_->stream_compression_ctx == NULL) {
+ if (s_->stream_compression_ctx == nullptr) {
s_->stream_compression_ctx =
grpc_stream_compression_context_create(s_->stream_compression_method);
}
s_->uncompressed_data_size = s_->flow_controlled_buffer.length;
if (!grpc_stream_compress(s_->stream_compression_ctx,
&s_->flow_controlled_buffer,
- &s_->compressed_data_buffer, NULL, MAX_SIZE_T,
+ &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
GRPC_STREAM_COMPRESSION_FLUSH_SYNC)) {
gpr_log(GPR_ERROR, "Stream compression failed.");
}
@@ -397,7 +398,7 @@ class StreamWriteContext {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_,
t_->is_client ? "CLIENT" : "SERVER", s->id,
- s->sent_initial_metadata, s->send_initial_metadata != NULL,
+ s->sent_initial_metadata, s->send_initial_metadata != nullptr,
(int)(s->flow_control->local_window_delta() -
s->flow_control->announced_window_delta())));
}
@@ -429,13 +430,13 @@ class StreamWriteContext {
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size
&s_->stats.outgoing // stats
};
- grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, NULL, 0,
+ grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, nullptr, 0,
s_->send_initial_metadata, &hopt, &t_->outbuf);
write_context_->ResetPingRecvClock();
write_context_->IncInitialMetadataWrites();
}
- s_->send_initial_metadata = NULL;
+ s_->send_initial_metadata = nullptr;
s_->sent_initial_metadata = true;
write_context_->NoteScheduledResults();
grpc_chttp2_complete_closure_step(
@@ -502,8 +503,8 @@ class StreamWriteContext {
void FlushTrailingMetadata(grpc_exec_ctx* exec_ctx) {
if (!s_->sent_initial_metadata) return;
- if (s_->send_trailing_metadata == NULL) return;
- if (s_->fetching_send_message != NULL) return;
+ if (s_->send_trailing_metadata == nullptr) return;
+ if (s_->fetching_send_message != nullptr) return;
if (s_->flow_controlled_buffer.length != 0) return;
if (s_->compressed_data_buffer.length != 0) return;
@@ -543,12 +544,12 @@ class StreamWriteContext {
gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)"));
// When sending Trailers-Only, we need to move the :status and
// content-type headers to the trailers.
- if (s_->send_initial_metadata->idx.named.status != NULL) {
+ if (s_->send_initial_metadata->idx.named.status != nullptr) {
extra_headers_for_trailing_metadata_
[num_extra_headers_for_trailing_metadata_++] =
&s_->send_initial_metadata->idx.named.status->md;
}
- if (s_->send_initial_metadata->idx.named.content_type != NULL) {
+ if (s_->send_initial_metadata->idx.named.content_type != nullptr) {
extra_headers_for_trailing_metadata_
[num_extra_headers_for_trailing_metadata_++] =
&s_->send_initial_metadata->idx.named.content_type->md;
@@ -556,7 +557,7 @@ class StreamWriteContext {
}
void SentLastFrame(grpc_exec_ctx* exec_ctx) {
- s_->send_trailing_metadata = NULL;
+ s_->send_trailing_metadata = nullptr;
s_->sent_trailing_metadata = true;
if (!t_->is_client && !s_->read_closed) {