diff options
Diffstat (limited to 'src/core/lib/security/credentials/google_default')
-rw-r--r-- | src/core/lib/security/credentials/google_default/credentials_generic.cc | 6 | ||||
-rw-r--r-- | src/core/lib/security/credentials/google_default/google_default_credentials.cc | 58 |
2 files changed, 32 insertions, 32 deletions
diff --git a/src/core/lib/security/credentials/google_default/credentials_generic.cc b/src/core/lib/security/credentials/google_default/credentials_generic.cc index c2a336ff07..58ee080cf3 100644 --- a/src/core/lib/security/credentials/google_default/credentials_generic.cc +++ b/src/core/lib/security/credentials/google_default/credentials_generic.cc @@ -26,12 +26,12 @@ #include "src/core/lib/support/string.h" char* grpc_get_well_known_google_credentials_file_path_impl(void) { - char* result = NULL; + char* result = nullptr; char* base = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR); - if (base == NULL) { + if (base == nullptr) { gpr_log(GPR_ERROR, "Could not get " GRPC_GOOGLE_CREDENTIALS_ENV_VAR " environment variable."); - return NULL; + return nullptr; } gpr_asprintf(&result, "%s/%s", base, GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX); gpr_free(base); diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 3ce19e9a05..f586c7b604 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -43,7 +43,7 @@ /* -- Default credentials. -- */ -static grpc_channel_credentials* default_credentials = NULL; +static grpc_channel_credentials* default_credentials = nullptr; static int compute_engine_detection_done = 0; static gpr_mu g_state_mu; static gpr_mu* g_polling_mu; @@ -80,8 +80,8 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx* exec_ctx, detector->is_done = 1; GRPC_LOG_IF_ERROR( "Pollset kick", - grpc_pollset_kick(exec_ctx, - grpc_polling_entity_pollset(&detector->pollent), NULL)); + grpc_pollset_kick( + exec_ctx, grpc_polling_entity_pollset(&detector->pollent), nullptr)); gpr_mu_unlock(g_polling_mu); } @@ -128,7 +128,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) { called once for the lifetime of the process by the default credentials. */ gpr_mu_lock(g_polling_mu); while (!detector.is_done) { - grpc_pollset_worker* worker = NULL; + grpc_pollset_worker* worker = nullptr; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(exec_ctx, @@ -147,7 +147,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) { grpc_pollset_shutdown(exec_ctx, grpc_polling_entity_pollset(&detector.pollent), &destroy_closure); - g_polling_mu = NULL; + g_polling_mu = nullptr; grpc_exec_ctx_flush(exec_ctx); gpr_free(grpc_polling_entity_pollset(&detector.pollent)); @@ -159,13 +159,13 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) { /* Takes ownership of creds_path if not NULL. */ static grpc_error* create_default_creds_from_path( grpc_exec_ctx* exec_ctx, char* creds_path, grpc_call_credentials** creds) { - grpc_json* json = NULL; + grpc_json* json = nullptr; grpc_auth_json_key key; grpc_auth_refresh_token token; - grpc_call_credentials* result = NULL; + grpc_call_credentials* result = nullptr; grpc_slice creds_data = grpc_empty_slice(); grpc_error* error = GRPC_ERROR_NONE; - if (creds_path == NULL) { + if (creds_path == nullptr) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("creds_path unset"); goto end; } @@ -175,7 +175,7 @@ static grpc_error* create_default_creds_from_path( } json = grpc_json_parse_string_with_len( (char*)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data)); - if (json == NULL) { + if (json == nullptr) { error = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"), GRPC_ERROR_STR_RAW_BYTES, grpc_slice_ref_internal(creds_data)); @@ -188,7 +188,7 @@ static grpc_error* create_default_creds_from_path( result = grpc_service_account_jwt_access_credentials_create_from_auth_json_key( exec_ctx, key, grpc_max_auth_token_lifetime()); - if (result == NULL) { + if (result == nullptr) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "grpc_service_account_jwt_access_credentials_create_from_auth_json_" "key failed"); @@ -201,7 +201,7 @@ static grpc_error* create_default_creds_from_path( if (grpc_auth_refresh_token_is_valid(&token)) { result = grpc_refresh_token_credentials_create_from_auth_refresh_token(token); - if (result == NULL) { + if (result == nullptr) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "grpc_refresh_token_credentials_create_from_auth_refresh_token " "failed"); @@ -210,17 +210,17 @@ static grpc_error* create_default_creds_from_path( } end: - GPR_ASSERT((result == NULL) + (error == GRPC_ERROR_NONE) == 1); - if (creds_path != NULL) gpr_free(creds_path); + GPR_ASSERT((result == nullptr) + (error == GRPC_ERROR_NONE) == 1); + if (creds_path != nullptr) gpr_free(creds_path); grpc_slice_unref_internal(exec_ctx, creds_data); - if (json != NULL) grpc_json_destroy(json); + if (json != nullptr) grpc_json_destroy(json); *creds = result; return error; } grpc_channel_credentials* grpc_google_default_credentials_create(void) { - grpc_channel_credentials* result = NULL; - grpc_call_credentials* call_creds = NULL; + grpc_channel_credentials* result = nullptr; + grpc_call_credentials* call_creds = nullptr; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Failed to create Google credentials"); grpc_error* err; @@ -232,7 +232,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) { gpr_mu_lock(&g_state_mu); - if (default_credentials != NULL) { + if (default_credentials != nullptr) { result = grpc_channel_credentials_ref(default_credentials); goto end; } @@ -257,8 +257,8 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) { is_stack_running_on_compute_engine(&exec_ctx); compute_engine_detection_done = 1; if (need_compute_engine_creds) { - call_creds = grpc_google_compute_engine_credentials_create(NULL); - if (call_creds == NULL) { + call_creds = grpc_google_compute_engine_credentials_create(nullptr); + if (call_creds == nullptr) { error = grpc_error_add_child( error, GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Failed to get credentials from network")); @@ -267,17 +267,17 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) { } end: - if (result == NULL) { - if (call_creds != NULL) { + if (result == nullptr) { + if (call_creds != nullptr) { /* Blend with default ssl credentials and add a global reference so that it can be cached and re-served. */ grpc_channel_credentials* ssl_creds = - grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_ssl_credentials_create(nullptr, nullptr, nullptr); default_credentials = grpc_channel_credentials_ref( grpc_composite_channel_credentials_create(ssl_creds, call_creds, - NULL)); - GPR_ASSERT(default_credentials != NULL); + nullptr)); + GPR_ASSERT(default_credentials != nullptr); grpc_channel_credentials_unref(&exec_ctx, ssl_creds); grpc_call_credentials_unref(&exec_ctx, call_creds); result = default_credentials; @@ -286,7 +286,7 @@ end: } } gpr_mu_unlock(&g_state_mu); - if (result == NULL) { + if (result == nullptr) { GRPC_LOG_IF_ERROR("grpc_google_default_credentials_create", error); } else { GRPC_ERROR_UNREF(error); @@ -299,9 +299,9 @@ void grpc_flush_cached_google_default_credentials(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_once_init(&g_once, init_default_credentials); gpr_mu_lock(&g_state_mu); - if (default_credentials != NULL) { + if (default_credentials != nullptr) { grpc_channel_credentials_unref(&exec_ctx, default_credentials); - default_credentials = NULL; + default_credentials = nullptr; } compute_engine_detection_done = 0; gpr_mu_unlock(&g_state_mu); @@ -310,10 +310,10 @@ void grpc_flush_cached_google_default_credentials(void) { /* -- Well known credentials path. -- */ -static grpc_well_known_credentials_path_getter creds_path_getter = NULL; +static grpc_well_known_credentials_path_getter creds_path_getter = nullptr; char* grpc_get_well_known_google_credentials_file_path(void) { - if (creds_path_getter != NULL) return creds_path_getter(); + if (creds_path_getter != nullptr) return creds_path_getter(); return grpc_get_well_known_google_credentials_file_path_impl(); } |