aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/transport
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2017-11-15 12:54:28 -0800
committerGravatar Mark D. Roth <roth@google.com>2017-11-15 12:54:28 -0800
commit03610f672e725a050224bf40540fc085bead1656 (patch)
tree360dc9d878d00458f8c65bc36197fb2719ba59d5 /src/core/lib/transport
parentfaeabfff5130a75f6f457384fcf6f6f1e092a611 (diff)
parent366e23b604d6458787ef8df77a2fed9c6d861f45 (diff)
Merge remote-tracking branch 'upstream/master' into server_connection_timeout
Diffstat (limited to 'src/core/lib/transport')
-rw-r--r--src/core/lib/transport/connectivity_state.cc18
-rw-r--r--src/core/lib/transport/error_utils.cc20
-rw-r--r--src/core/lib/transport/metadata.cc20
-rw-r--r--src/core/lib/transport/metadata_batch.cc39
-rw-r--r--src/core/lib/transport/service_config.cc92
-rw-r--r--src/core/lib/transport/transport.cc5
-rw-r--r--src/core/lib/transport/transport_op_string.cc18
7 files changed, 106 insertions, 106 deletions
diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc
index bdaf0243f9..55f4236d57 100644
--- a/src/core/lib/transport/connectivity_state.cc
+++ b/src/core/lib/transport/connectivity_state.cc
@@ -48,7 +48,7 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker,
const char* name) {
gpr_atm_no_barrier_store(&tracker->current_state_atm, init_state);
tracker->current_error = GRPC_ERROR_NONE;
- tracker->watchers = NULL;
+ tracker->watchers = nullptr;
tracker->name = gpr_strdup(name);
}
@@ -94,7 +94,7 @@ grpc_connectivity_state grpc_connectivity_state_get(
gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name,
grpc_connectivity_state_name(cur));
}
- if (error != NULL) {
+ if (error != nullptr) {
*error = GRPC_ERROR_REF(tracker->current_error);
}
return cur;
@@ -102,7 +102,7 @@ grpc_connectivity_state grpc_connectivity_state_get(
bool grpc_connectivity_state_has_watchers(
grpc_connectivity_state_tracker* connectivity_state) {
- return connectivity_state->watchers != NULL;
+ return connectivity_state->watchers != nullptr;
}
bool grpc_connectivity_state_notify_on_state_change(
@@ -112,7 +112,7 @@ bool grpc_connectivity_state_notify_on_state_change(
(grpc_connectivity_state)gpr_atm_no_barrier_load(
&tracker->current_state_atm);
if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
- if (current == NULL) {
+ if (current == nullptr) {
gpr_log(GPR_DEBUG, "CONWATCH: %p %s: unsubscribe notify=%p", tracker,
tracker->name, notify);
} else {
@@ -121,17 +121,17 @@ bool grpc_connectivity_state_notify_on_state_change(
grpc_connectivity_state_name(cur), notify);
}
}
- if (current == NULL) {
+ if (current == nullptr) {
grpc_connectivity_state_watcher* w = tracker->watchers;
- if (w != NULL && w->notify == notify) {
+ if (w != nullptr && w->notify == notify) {
GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
tracker->watchers = w->next;
gpr_free(w);
return false;
}
- while (w != NULL) {
+ while (w != nullptr) {
grpc_connectivity_state_watcher* rm_candidate = w->next;
- if (rm_candidate != NULL && rm_candidate->notify == notify) {
+ if (rm_candidate != nullptr && rm_candidate->notify == notify) {
GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
w->next = w->next->next;
gpr_free(rm_candidate);
@@ -189,7 +189,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx,
}
GPR_ASSERT(cur != GRPC_CHANNEL_SHUTDOWN);
gpr_atm_no_barrier_store(&tracker->current_state_atm, state);
- while ((w = tracker->watchers) != NULL) {
+ while ((w = tracker->watchers) != nullptr) {
*w->current = state;
tracker->watchers = w->next;
if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc
index d968b04fd8..19510b4c8d 100644
--- a/src/core/lib/transport/error_utils.cc
+++ b/src/core/lib/transport/error_utils.cc
@@ -24,10 +24,10 @@
static grpc_error* recursively_find_error_with_field(grpc_error* error,
grpc_error_ints which) {
// If the error itself has a status code, return it.
- if (grpc_error_get_int(error, which, NULL)) {
+ if (grpc_error_get_int(error, which, nullptr)) {
return error;
}
- if (grpc_error_is_special(error)) return NULL;
+ if (grpc_error_is_special(error)) return nullptr;
// Otherwise, search through its children.
uint8_t slot = error->first_err;
while (slot != UINT8_MAX) {
@@ -36,7 +36,7 @@ static grpc_error* recursively_find_error_with_field(grpc_error* error,
if (result) return result;
slot = lerr->next;
}
- return NULL;
+ return nullptr;
}
void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
@@ -47,7 +47,7 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
// until we find the first one that has a status code.
grpc_error* found_error =
recursively_find_error_with_field(error, GRPC_ERROR_INT_GRPC_STATUS);
- if (found_error == NULL) {
+ if (found_error == nullptr) {
/// If no grpc-status exists, retry through the tree to find a http2 error
/// code
found_error =
@@ -56,7 +56,7 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
// If we found an error with a status code above, use that; otherwise,
// fall back to using the parent error.
- if (found_error == NULL) found_error = error;
+ if (found_error == nullptr) found_error = error;
grpc_status_code status = GRPC_STATUS_UNKNOWN;
intptr_t integer;
@@ -67,9 +67,9 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
status = grpc_http2_error_to_grpc_status(
exec_ctx, (grpc_http2_error_code)integer, deadline);
}
- if (code != NULL) *code = status;
+ if (code != nullptr) *code = status;
- if (http_error != NULL) {
+ if (http_error != nullptr) {
if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR, &integer)) {
*http_error = (grpc_http2_error_code)integer;
} else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_GRPC_STATUS,
@@ -83,19 +83,17 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
// If the error has a status message, use it. Otherwise, fall back to
// the error description.
- if (slice != NULL) {
+ if (slice != nullptr) {
if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_GRPC_MESSAGE, slice)) {
if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_DESCRIPTION, slice)) {
*slice = grpc_slice_from_static_string("unknown error");
}
}
}
-
- if (found_error == NULL) found_error = error;
}
bool grpc_error_has_clear_grpc_status(grpc_error* error) {
- if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, NULL)) {
+ if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, nullptr)) {
return true;
}
uint8_t slot = error->first_err;
diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc
index ff11ddec13..a16f0508f0 100644
--- a/src/core/lib/transport/metadata.cc
+++ b/src/core/lib/transport/metadata.cc
@@ -241,7 +241,7 @@ grpc_mdelem grpc_mdelem_create(
grpc_exec_ctx* exec_ctx, grpc_slice key, grpc_slice value,
grpc_mdelem_data* compatible_external_backing_store) {
if (!grpc_slice_is_interned(key) || !grpc_slice_is_interned(value)) {
- if (compatible_external_backing_store != NULL) {
+ if (compatible_external_backing_store != nullptr) {
return GRPC_MAKE_MDELEM(compatible_external_backing_store,
GRPC_MDELEM_STORAGE_EXTERNAL);
}
@@ -330,7 +330,7 @@ grpc_mdelem grpc_mdelem_create(
grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx* exec_ctx, grpc_slice key,
grpc_slice value) {
- grpc_mdelem out = grpc_mdelem_create(exec_ctx, key, value, NULL);
+ grpc_mdelem out = grpc_mdelem_create(exec_ctx, key, value, nullptr);
grpc_slice_unref_internal(exec_ctx, key);
grpc_slice_unref_internal(exec_ctx, value);
return out;
@@ -344,7 +344,7 @@ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx* exec_ctx,
grpc_slice value_slice =
grpc_slice_maybe_static_intern(metadata->value, &changed);
return grpc_mdelem_create(exec_ctx, key_slice, value_slice,
- changed ? NULL : (grpc_mdelem_data*)metadata);
+ changed ? nullptr : (grpc_mdelem_data*)metadata);
}
static size_t get_base64_encoded_size(size_t raw_length) {
@@ -478,7 +478,7 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) {
switch (GRPC_MDELEM_STORAGE(md)) {
case GRPC_MDELEM_STORAGE_EXTERNAL:
case GRPC_MDELEM_STORAGE_ALLOCATED:
- return NULL;
+ return nullptr;
case GRPC_MDELEM_STORAGE_STATIC:
return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) -
grpc_static_mdelem_table];
@@ -488,12 +488,12 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) {
if (gpr_atm_acq_load(&im->destroy_user_data) == (gpr_atm)destroy_func) {
return (void*)gpr_atm_no_barrier_load(&im->user_data);
} else {
- return NULL;
+ return nullptr;
}
return result;
}
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
@@ -502,7 +502,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
case GRPC_MDELEM_STORAGE_EXTERNAL:
case GRPC_MDELEM_STORAGE_ALLOCATED:
destroy_func(user_data);
- return NULL;
+ return nullptr;
case GRPC_MDELEM_STORAGE_STATIC:
destroy_func(user_data);
return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) -
@@ -510,12 +510,12 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
case GRPC_MDELEM_STORAGE_INTERNED: {
interned_metadata* im = (interned_metadata*)GRPC_MDELEM_DATA(md);
GPR_ASSERT(!is_mdelem_static(md));
- GPR_ASSERT((user_data == NULL) == (destroy_func == NULL));
+ GPR_ASSERT((user_data == nullptr) == (destroy_func == nullptr));
gpr_mu_lock(&im->mu_user_data);
if (gpr_atm_no_barrier_load(&im->destroy_user_data)) {
/* user data can only be set once */
gpr_mu_unlock(&im->mu_user_data);
- if (destroy_func != NULL) {
+ if (destroy_func != nullptr) {
destroy_func(user_data);
}
return (void*)gpr_atm_no_barrier_load(&im->user_data);
@@ -526,7 +526,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
return user_data;
}
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b) {
diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc
index 90e84cd1e2..5817765aa3 100644
--- a/src/core/lib/transport/metadata_batch.cc
+++ b/src/core/lib/transport/metadata_batch.cc
@@ -32,17 +32,17 @@ static void assert_valid_list(grpc_mdelem_list* list) {
#ifndef NDEBUG
grpc_linked_mdelem* l;
- GPR_ASSERT((list->head == NULL) == (list->tail == NULL));
+ GPR_ASSERT((list->head == nullptr) == (list->tail == nullptr));
if (!list->head) return;
- GPR_ASSERT(list->head->prev == NULL);
- GPR_ASSERT(list->tail->next == NULL);
- GPR_ASSERT((list->head == list->tail) == (list->head->next == NULL));
+ GPR_ASSERT(list->head->prev == nullptr);
+ GPR_ASSERT(list->tail->next == nullptr);
+ GPR_ASSERT((list->head == list->tail) == (list->head->next == nullptr));
size_t verified_count = 0;
for (l = list->head; l; l = l->next) {
GPR_ASSERT(!GRPC_MDISNULL(l->md));
- GPR_ASSERT((l->prev == NULL) == (l == list->head));
- GPR_ASSERT((l->next == NULL) == (l == list->tail));
+ GPR_ASSERT((l->prev == nullptr) == (l == list->head));
+ GPR_ASSERT((l->next == nullptr) == (l == list->tail));
if (l->next) GPR_ASSERT(l->next->prev == l);
if (l->prev) GPR_ASSERT(l->prev->next == l);
verified_count++;
@@ -54,7 +54,7 @@ static void assert_valid_list(grpc_mdelem_list* list) {
static void assert_valid_callouts(grpc_exec_ctx* exec_ctx,
grpc_metadata_batch* batch) {
#ifndef NDEBUG
- for (grpc_linked_mdelem* l = batch->list.head; l != NULL; l = l->next) {
+ for (grpc_linked_mdelem* l = batch->list.head; l != nullptr; l = l->next) {
grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md));
grpc_metadata_batch_callouts_index callout_idx =
GRPC_BATCH_INDEX_OF(key_interned);
@@ -104,7 +104,7 @@ static grpc_error* maybe_link_callout(grpc_metadata_batch* batch,
if (idx == GRPC_BATCH_CALLOUTS_COUNT) {
return GRPC_ERROR_NONE;
}
- if (batch->idx.array[idx] == NULL) {
+ if (batch->idx.array[idx] == nullptr) {
if (grpc_static_callout_is_default[idx]) ++batch->list.default_count;
batch->idx.array[idx] = storage;
return GRPC_ERROR_NONE;
@@ -122,8 +122,8 @@ static void maybe_unlink_callout(grpc_metadata_batch* batch,
return;
}
if (grpc_static_callout_is_default[idx]) --batch->list.default_count;
- GPR_ASSERT(batch->idx.array[idx] != NULL);
- batch->idx.array[idx] = NULL;
+ GPR_ASSERT(batch->idx.array[idx] != nullptr);
+ batch->idx.array[idx] = nullptr;
}
grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx,
@@ -138,9 +138,9 @@ grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx,
static void link_head(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
assert_valid_list(list);
GPR_ASSERT(!GRPC_MDISNULL(storage->md));
- storage->prev = NULL;
+ storage->prev = nullptr;
storage->next = list->head;
- if (list->head != NULL) {
+ if (list->head != nullptr) {
list->head->prev = storage;
} else {
list->tail = storage;
@@ -177,9 +177,9 @@ static void link_tail(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
assert_valid_list(list);
GPR_ASSERT(!GRPC_MDISNULL(storage->md));
storage->prev = list->tail;
- storage->next = NULL;
- storage->reserved = NULL;
- if (list->tail != NULL) {
+ storage->next = nullptr;
+ storage->reserved = nullptr;
+ if (list->tail != nullptr) {
list->tail->next = storage;
} else {
list->head = storage;
@@ -206,12 +206,12 @@ grpc_error* grpc_metadata_batch_link_tail(grpc_exec_ctx* exec_ctx,
static void unlink_storage(grpc_mdelem_list* list,
grpc_linked_mdelem* storage) {
assert_valid_list(list);
- if (storage->prev != NULL) {
+ if (storage->prev != nullptr) {
storage->prev->next = storage->next;
} else {
list->head = storage->next;
}
- if (storage->next != NULL) {
+ if (storage->next != nullptr) {
storage->next->prev = storage->prev;
} else {
list->tail = storage->prev;
@@ -270,12 +270,13 @@ void grpc_metadata_batch_clear(grpc_exec_ctx* exec_ctx,
}
bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch) {
- return batch->list.head == NULL && batch->deadline == GRPC_MILLIS_INF_FUTURE;
+ return batch->list.head == nullptr &&
+ batch->deadline == GRPC_MILLIS_INF_FUTURE;
}
size_t grpc_metadata_batch_size(grpc_metadata_batch* batch) {
size_t size = 0;
- for (grpc_linked_mdelem* elem = batch->list.head; elem != NULL;
+ for (grpc_linked_mdelem* elem = batch->list.head; elem != nullptr;
elem = elem->next) {
size += GRPC_MDELEM_LENGTH(elem->md);
}
diff --git a/src/core/lib/transport/service_config.cc b/src/core/lib/transport/service_config.cc
index 05907de7d7..adcec8c444 100644
--- a/src/core/lib/transport/service_config.cc
+++ b/src/core/lib/transport/service_config.cc
@@ -64,11 +64,11 @@ grpc_service_config* grpc_service_config_create(const char* json_string) {
service_config->json_string = gpr_strdup(json_string);
service_config->json_tree =
grpc_json_parse_string(service_config->json_string);
- if (service_config->json_tree == NULL) {
+ if (service_config->json_tree == nullptr) {
gpr_log(GPR_INFO, "failed to parse JSON for service config");
gpr_free(service_config->json_string);
gpr_free(service_config);
- return NULL;
+ return nullptr;
}
return service_config;
}
@@ -83,9 +83,9 @@ void grpc_service_config_parse_global_params(
const grpc_service_config* service_config,
void (*process_json)(const grpc_json* json, void* arg), void* arg) {
const grpc_json* json = service_config->json_tree;
- if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) return;
+ if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) return;
if (strcmp(field->key, "methodConfig") == 0) continue;
process_json(field, arg);
}
@@ -94,13 +94,13 @@ void grpc_service_config_parse_global_params(
const char* grpc_service_config_get_lb_policy_name(
const grpc_service_config* service_config) {
const grpc_json* json = service_config->json_tree;
- if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL;
- const char* lb_policy_name = NULL;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) return NULL;
+ if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr;
+ const char* lb_policy_name = nullptr;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) return nullptr;
if (strcmp(field->key, "loadBalancingPolicy") == 0) {
- if (lb_policy_name != NULL) return NULL; // Duplicate.
- if (field->type != GRPC_JSON_STRING) return NULL;
+ if (lb_policy_name != nullptr) return nullptr; // Duplicate.
+ if (field->type != GRPC_JSON_STRING) return nullptr;
lb_policy_name = field->value;
}
}
@@ -110,10 +110,10 @@ const char* grpc_service_config_get_lb_policy_name(
// Returns the number of names specified in the method config \a json.
static size_t count_names_in_method_config_json(grpc_json* json) {
size_t num_names = 0;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key != NULL && strcmp(field->key, "name") == 0) {
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key != nullptr && strcmp(field->key, "name") == 0) {
if (field->type != GRPC_JSON_ARRAY) return -1;
- for (grpc_json* name = field->child; name != NULL; name = name->next) {
+ for (grpc_json* name = field->child; name != nullptr; name = name->next) {
if (name->type != GRPC_JSON_OBJECT) return -1;
++num_names;
}
@@ -125,26 +125,26 @@ static size_t count_names_in_method_config_json(grpc_json* json) {
// Returns a path string for the JSON name object specified by \a json.
// Returns NULL on error. Caller takes ownership of result.
static char* parse_json_method_name(grpc_json* json) {
- if (json->type != GRPC_JSON_OBJECT) return NULL;
- const char* service_name = NULL;
- const char* method_name = NULL;
- for (grpc_json* child = json->child; child != NULL; child = child->next) {
- if (child->key == NULL) return NULL;
- if (child->type != GRPC_JSON_STRING) return NULL;
+ if (json->type != GRPC_JSON_OBJECT) return nullptr;
+ const char* service_name = nullptr;
+ const char* method_name = nullptr;
+ for (grpc_json* child = json->child; child != nullptr; child = child->next) {
+ if (child->key == nullptr) return nullptr;
+ if (child->type != GRPC_JSON_STRING) return nullptr;
if (strcmp(child->key, "service") == 0) {
- if (service_name != NULL) return NULL; // Duplicate.
- if (child->value == NULL) return NULL;
+ if (service_name != nullptr) return nullptr; // Duplicate.
+ if (child->value == nullptr) return nullptr;
service_name = child->value;
} else if (strcmp(child->key, "method") == 0) {
- if (method_name != NULL) return NULL; // Duplicate.
- if (child->value == NULL) return NULL;
+ if (method_name != nullptr) return nullptr; // Duplicate.
+ if (child->value == nullptr) return nullptr;
method_name = child->value;
}
}
- if (service_name == NULL) return NULL; // Required field.
+ if (service_name == nullptr) return nullptr; // Required field.
char* path;
gpr_asprintf(&path, "/%s/%s", service_name,
- method_name == NULL ? "*" : method_name);
+ method_name == nullptr ? "*" : method_name);
return path;
}
@@ -159,18 +159,18 @@ static bool parse_json_method_config(
grpc_slice_hash_table_entry* entries, size_t* idx) {
// Construct value.
void* method_config = create_value(json);
- if (method_config == NULL) return false;
+ if (method_config == nullptr) return false;
// Construct list of paths.
bool success = false;
gpr_strvec paths;
gpr_strvec_init(&paths);
- for (grpc_json* child = json->child; child != NULL; child = child->next) {
- if (child->key == NULL) continue;
+ for (grpc_json* child = json->child; child != nullptr; child = child->next) {
+ if (child->key == nullptr) continue;
if (strcmp(child->key, "name") == 0) {
if (child->type != GRPC_JSON_ARRAY) goto done;
- for (grpc_json* name = child->child; name != NULL; name = name->next) {
+ for (grpc_json* name = child->child; name != nullptr; name = name->next) {
char* path = parse_json_method_name(name);
- if (path == NULL) goto done;
+ if (path == nullptr) goto done;
gpr_strvec_add(&paths, path);
}
}
@@ -196,26 +196,26 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
void (*unref_value)(grpc_exec_ctx* exec_ctx, void* value)) {
const grpc_json* json = service_config->json_tree;
// Traverse parsed JSON tree.
- if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL;
+ if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr;
size_t num_entries = 0;
- grpc_slice_hash_table_entry* entries = NULL;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) return NULL;
+ grpc_slice_hash_table_entry* entries = nullptr;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) return nullptr;
if (strcmp(field->key, "methodConfig") == 0) {
- if (entries != NULL) return NULL; // Duplicate.
- if (field->type != GRPC_JSON_ARRAY) return NULL;
+ if (entries != nullptr) return nullptr; // Duplicate.
+ if (field->type != GRPC_JSON_ARRAY) return nullptr;
// Find number of entries.
- for (grpc_json* method = field->child; method != NULL;
+ for (grpc_json* method = field->child; method != nullptr;
method = method->next) {
size_t count = count_names_in_method_config_json(method);
- if (count <= 0) return NULL;
+ if (count <= 0) return nullptr;
num_entries += count;
}
// Populate method config table entries.
entries = (grpc_slice_hash_table_entry*)gpr_malloc(
num_entries * sizeof(grpc_slice_hash_table_entry));
size_t idx = 0;
- for (grpc_json* method = field->child; method != NULL;
+ for (grpc_json* method = field->child; method != nullptr;
method = method->next) {
if (!parse_json_method_config(exec_ctx, method, create_value, ref_value,
unref_value, entries, &idx)) {
@@ -224,17 +224,17 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
unref_value(exec_ctx, entries[i].value);
}
gpr_free(entries);
- return NULL;
+ return nullptr;
}
}
GPR_ASSERT(idx == num_entries);
}
}
// Instantiate method config table.
- grpc_slice_hash_table* method_config_table = NULL;
- if (entries != NULL) {
- method_config_table =
- grpc_slice_hash_table_create(num_entries, entries, unref_value, NULL);
+ grpc_slice_hash_table* method_config_table = nullptr;
+ if (entries != nullptr) {
+ method_config_table = grpc_slice_hash_table_create(num_entries, entries,
+ unref_value, nullptr);
gpr_free(entries);
}
return method_config_table;
@@ -246,7 +246,7 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
void* value = grpc_slice_hash_table_get(table, path);
// If we didn't find a match for the path, try looking for a wildcard
// entry (i.e., change "/service/method" to "/service/*").
- if (value == NULL) {
+ if (value == nullptr) {
char* path_str = grpc_slice_to_c_string(path);
const char* sep = strrchr(path_str, '/') + 1;
const size_t len = (size_t)(sep - path_str);
diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc
index 021f1b799b..b39e6ebc30 100644
--- a/src/core/lib/transport/transport.cc
+++ b/src/core/lib/transport/transport.cc
@@ -184,9 +184,10 @@ void grpc_transport_set_pops(grpc_exec_ctx* exec_ctx, grpc_transport* transport,
grpc_polling_entity* pollent) {
grpc_pollset* pollset;
grpc_pollset_set* pollset_set;
- if ((pollset = grpc_polling_entity_pollset(pollent)) != NULL) {
+ if ((pollset = grpc_polling_entity_pollset(pollent)) != nullptr) {
transport->vtable->set_pollset(exec_ctx, transport, stream, pollset);
- } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) != NULL) {
+ } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) !=
+ nullptr) {
transport->vtable->set_pollset_set(exec_ctx, transport, stream,
pollset_set);
} else {
diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc
index 24e74c10c5..e69ab02570 100644
--- a/src/core/lib/transport/transport_op_string.cc
+++ b/src/core/lib/transport/transport_op_string.cc
@@ -47,7 +47,7 @@ static void put_metadata(gpr_strvec* b, grpc_mdelem md) {
static void put_metadata_list(gpr_strvec* b, grpc_metadata_batch md) {
grpc_linked_mdelem* m;
- for (m = md.list.head; m != NULL; m = m->next) {
+ for (m = md.list.head; m != nullptr; m = m->next) {
if (m != md.list.head) gpr_strvec_add(b, gpr_strdup(", "));
put_metadata(b, m->md);
}
@@ -121,7 +121,7 @@ char* grpc_transport_stream_op_batch_string(
gpr_strvec_add(&b, tmp);
}
- out = gpr_strvec_flatten(&b, NULL);
+ out = gpr_strvec_flatten(&b, nullptr);
gpr_strvec_destroy(&b);
return out;
@@ -135,10 +135,10 @@ char* grpc_transport_op_string(grpc_transport_op* op) {
gpr_strvec b;
gpr_strvec_init(&b);
- if (op->on_connectivity_state_change != NULL) {
+ if (op->on_connectivity_state_change != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
- if (op->connectivity_state != NULL) {
+ if (op->connectivity_state != nullptr) {
gpr_asprintf(&tmp, "ON_CONNECTIVITY_STATE_CHANGE:p=%p:from=%s",
op->on_connectivity_state_change,
grpc_connectivity_state_name(*op->connectivity_state));
@@ -175,25 +175,25 @@ char* grpc_transport_op_string(grpc_transport_op* op) {
gpr_strvec_add(&b, tmp);
}
- if (op->bind_pollset != NULL) {
+ if (op->bind_pollset != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET"));
}
- if (op->bind_pollset_set != NULL) {
+ if (op->bind_pollset_set != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET_SET"));
}
- if (op->send_ping != NULL) {
+ if (op->send_ping != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
- first = false;
+ // first = false;
gpr_strvec_add(&b, gpr_strdup("SEND_PING"));
}
- out = gpr_strvec_flatten(&b, NULL);
+ out = gpr_strvec_flatten(&b, nullptr);
gpr_strvec_destroy(&b);
return out;