Run clang_format_all_the_things.sh

pull/20565/head
Carlos O'Ryan 5 years ago
parent b3c4c49e36
commit 2144c719fc
No known key found for this signature in database
GPG Key ID: BC4C1DC8B0DEF583
  1. 24
      src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
  2. 16
      test/core/security/check_gcp_environment_windows_test.cc

@ -34,12 +34,11 @@
namespace grpc_core { namespace grpc_core {
namespace internal { namespace internal {
bool check_bios_data(const char*) { bool check_bios_data(const char*) { return false; }
return false;
}
bool check_windows_registry_product_name( bool check_windows_registry_product_name(HKEY root_key,
HKEY root_key, const char* reg_key_path, const char* reg_key_name) { const char* reg_key_path,
const char* reg_key_name) {
const size_t kProductNameBufferSize = 256; const size_t kProductNameBufferSize = 256;
char const expected_substr[] = "Google"; char const expected_substr[] = "Google";
@ -47,8 +46,7 @@ bool check_windows_registry_product_name(
// enough space for the trailing NUL character that will be included. // enough space for the trailing NUL character that will be included.
DWORD buffer_size{}; DWORD buffer_size{};
auto rc = ::RegGetValueA( auto rc = ::RegGetValueA(
root_key, reg_key_path, reg_key_name, root_key, reg_key_path, reg_key_name, RRF_RT_REG_SZ,
RRF_RT_REG_SZ,
nullptr, // We know the type will be REG_SZ. nullptr, // We know the type will be REG_SZ.
nullptr, // We're only fetching the size; no buffer given yet. nullptr, // We're only fetching the size; no buffer given yet.
&buffer_size); // Fetch the size in bytes of the value, if it exists. &buffer_size); // Fetch the size in bytes of the value, if it exists.
@ -64,10 +62,9 @@ bool check_windows_registry_product_name(
char buffer[kProductNameBufferSize]; char buffer[kProductNameBufferSize];
buffer_size = kProductNameBufferSize; buffer_size = kProductNameBufferSize;
rc = ::RegGetValueA( rc = ::RegGetValueA(
root_key, reg_key_path, reg_key_name, root_key, reg_key_path, reg_key_name, RRF_RT_REG_SZ,
RRF_RT_REG_SZ, nullptr, // We know the type will be REG_SZ.
nullptr, // We know the type will be REG_SZ. static_cast<void*>(buffer), // Fetch the string value this time.
static_cast<void*>(buffer), // Fetch the string value this time.
&buffer_size); // The string size in bytes, not including trailing NUL. &buffer_size); // The string size in bytes, not including trailing NUL.
if (rc != 0) { if (rc != 0) {
return false; return false;
@ -93,8 +90,9 @@ bool grpc_alts_is_running_on_gcp() {
gpr_once_init(&g_once, init_mu); gpr_once_init(&g_once, init_mu);
gpr_mu_lock(&g_mu); gpr_mu_lock(&g_mu);
if (!g_compute_engine_detection_done) { if (!g_compute_engine_detection_done) {
g_is_on_compute_engine = grpc_core::internal::check_windows_registry_product_name( g_is_on_compute_engine =
HKEY_LOCAL_MACHINE, reg_key_path, reg_key_name); grpc_core::internal::check_windows_registry_product_name(
HKEY_LOCAL_MACHINE, reg_key_path, reg_key_name);
g_compute_engine_detection_done = true; g_compute_engine_detection_done = true;
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);

@ -32,8 +32,9 @@
namespace grpc_core { namespace grpc_core {
namespace internal { namespace internal {
bool check_windows_registry_product_name( bool check_windows_registry_product_name(HKEY root_key,
HKEY root_key, const char* reg_key_path, const char* reg_key_name); const char* reg_key_path,
const char* reg_key_name);
} // namespace internal } // namespace internal
} // namespace grpc_core } // namespace grpc_core
@ -44,17 +45,16 @@ static bool check_bios_data_windows_test(const char* data) {
// Modify the registry for the current user to contain the // Modify the registry for the current user to contain the
// test value. We cannot use the system registry because the // test value. We cannot use the system registry because the
// user may not have privileges to change it. // user may not have privileges to change it.
auto rc = RegSetKeyValueA( auto rc = RegSetKeyValueA(HKEY_CURRENT_USER, reg_key_path, reg_key_name,
HKEY_CURRENT_USER, reg_key_path, reg_key_name, REG_SZ, REG_SZ, reinterpret_cast<const BYTE*>(data),
reinterpret_cast<const BYTE*>(data), static_cast<DWORD>(strlen(data)));
static_cast<DWORD>(strlen(data)));
if (rc != 0) { if (rc != 0) {
return false; return false;
} }
auto result = grpc_core::internal::check_windows_registry_product_name( auto result = grpc_core::internal::check_windows_registry_product_name(
HKEY_CURRENT_USER, reg_key_path, reg_key_name); HKEY_CURRENT_USER, reg_key_path, reg_key_name);
(void)RegDeleteKeyValueA(HKEY_CURRENT_USER, reg_key_path, reg_key_name); (void)RegDeleteKeyValueA(HKEY_CURRENT_USER, reg_key_path, reg_key_name);
return result; return result;

Loading…
Cancel
Save