Skip to content

Commit e3e8a08

Browse files
committed
Format code.
1 parent ab86de9 commit e3e8a08

File tree

3 files changed

+39
-27
lines changed

3 files changed

+39
-27
lines changed

analytics/src/analytics_desktop.cc

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#if defined(_WIN32)
3030
#include <windows.h>
3131

32-
// analytics_windows.h is not strictly needed if only using C API via analytics_desktop_dynamic.h
33-
// #include "analytics/src/analytics_windows.h"
32+
// analytics_windows.h is not strictly needed if only using C API via
33+
// analytics_desktop_dynamic.h #include "analytics/src/analytics_windows.h"
3434
#endif // defined(_WIN32)
3535

3636
namespace firebase {
@@ -67,17 +67,18 @@ void Initialize(const App& app) {
6767
#if defined(_WIN32)
6868
if (!g_analytics_module) {
6969
std::vector<std::string> allowed_hashes;
70-
for (int i=0; i < FirebaseAnalytics_KnownWindowsDllHashCount; i++) {
71-
allowed_hashes.push_back(std::string(FirebaseAnalytics_KnownWindowsDllHashes[i]));
70+
for (int i = 0; i < FirebaseAnalytics_KnownWindowsDllHashCount; i++) {
71+
allowed_hashes.push_back(
72+
std::string(FirebaseAnalytics_KnownWindowsDllHashes[i]));
7273
}
7374

7475
g_analytics_module =
7576
firebase::analytics::internal::VerifyAndLoadAnalyticsLibrary(
7677
ANALYTICS_DLL_FILENAME, allowed_hashes);
7778

7879
if (g_analytics_module) {
79-
int num_loaded = FirebaseAnalytics_LoadDynamicFunctions(
80-
g_analytics_module);
80+
int num_loaded =
81+
FirebaseAnalytics_LoadDynamicFunctions(g_analytics_module);
8182
if (num_loaded < FirebaseAnalytics_DynamicFunctionCount) {
8283
LogWarning(
8384
"Analytics: Failed to load functions from Google Analytics "
@@ -101,23 +102,29 @@ void Initialize(const App& app) {
101102
c_options->app_id = current_app_id.c_str();
102103
c_options->package_name = current_package_name.c_str();
103104
c_options->analytics_collection_enabled_at_first_launch = true;
104-
// c_options->reserved is initialized by GoogleAnalytics_Options_Create
105+
// c_options->reserved is initialized by
106+
// GoogleAnalytics_Options_Create
105107

106-
LogInfo("Analytics: Initializing Google Analytics C API with App ID: %s, Package Name: %s",
107-
c_options->app_id ? c_options->app_id : "null",
108-
c_options->package_name ? c_options->package_name : "null");
108+
LogInfo(
109+
"Analytics: Initializing Google Analytics C API with App ID: %s, "
110+
"Package Name: %s",
111+
c_options->app_id ? c_options->app_id : "null",
112+
c_options->package_name ? c_options->package_name : "null");
109113

110114
if (!GoogleAnalytics_Initialize(c_options)) {
111115
LogError("Analytics: Failed to initialize Google Analytics C API.");
112-
// GoogleAnalytics_Initialize destroys c_options automatically if created by _Create
116+
// GoogleAnalytics_Initialize destroys c_options automatically if
117+
// created by _Create
113118
} else {
114-
LogInfo("Analytics: Google Analytics C API initialized successfully.");
119+
LogInfo(
120+
"Analytics: Google Analytics C API initialized successfully.");
115121
}
116122
}
117123
}
118124
} else {
119-
// LogWarning for g_analytics_module load failure is handled by VerifyAndLoadAnalyticsLibrary
120-
g_analytics_module = 0; // Ensure it's null if loading failed
125+
// LogWarning for g_analytics_module load failure is handled by
126+
// VerifyAndLoadAnalyticsLibrary
127+
g_analytics_module = 0; // Ensure it's null if loading failed
121128
}
122129
}
123130
#endif // defined(_WIN32)

analytics/src/analytics_desktop_dynamic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
#include <stddef.h>
2020

21-
// A nice big chunk of stub memory that can be returned by stubbed Create methods.
21+
// A nice big chunk of stub memory that can be returned by stubbed Create
22+
// methods.
2223
static char g_stub_memory[256] = {0};
2324

2425
// clang-format off

analytics/src/analytics_windows.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ static std::string CalculateFileSha256(HANDLE hFile) {
9999
DWORD dwError = GetLastError();
100100
LogError(LOG_TAG "CalculateFileSha256.SetFilePointer failed. Error: %u",
101101
dwError);
102-
return ""; // Return empty string on failure
102+
return ""; // Return empty string on failure
103103
}
104104

105105
// Acquire Crypto Provider.
106-
// Using CRYPT_VERIFYCONTEXT for operations that don't require private key access.
106+
// Using CRYPT_VERIFYCONTEXT for operations that don't require private key
107+
// access.
107108
if (!CryptAcquireContextW(&hProv, NULL, NULL, PROV_RSA_AES,
108109
CRYPT_VERIFYCONTEXT)) {
109110
DWORD dwError = GetLastError();
@@ -152,7 +153,8 @@ static std::string CalculateFileSha256(HANDLE hFile) {
152153
// --- Get the binary hash value ---
153154
DWORD cbHashValue = 0;
154155
DWORD dwCount = sizeof(DWORD);
155-
if (!CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashValue, &dwCount, 0)) {
156+
if (!CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashValue, &dwCount,
157+
0)) {
156158
DWORD dwError = GetLastError();
157159
LogError(LOG_TAG
158160
"CalculateFileSha256.CryptGetHashParam (HP_HASHSIZE) failed. "
@@ -179,12 +181,13 @@ static std::string CalculateFileSha256(HANDLE hFile) {
179181
// --- Convert the binary hash to a hex string ---
180182
DWORD hex_string_size = 0;
181183
if (!CryptBinaryToStringA(binary_hash_value.data(), binary_hash_value.size(),
182-
CRYPT_STRING_HEXRAW | CRYPT_STRING_NOCRLF,
183-
NULL, &hex_string_size)) {
184+
CRYPT_STRING_HEXRAW | CRYPT_STRING_NOCRLF, NULL,
185+
&hex_string_size)) {
184186
DWORD dwError = GetLastError();
185-
LogError(LOG_TAG
186-
"CalculateFileSha256.CryptBinaryToStringA (size) failed. Error: %u",
187-
dwError);
187+
LogError(
188+
LOG_TAG
189+
"CalculateFileSha256.CryptBinaryToStringA (size) failed. Error: %u",
190+
dwError);
188191
CryptDestroyHash(hHash);
189192
CryptReleaseContext(hProv, 0);
190193
return "";
@@ -196,7 +199,8 @@ static std::string CalculateFileSha256(HANDLE hFile) {
196199
&hex_hash_string[0], &hex_string_size)) {
197200
DWORD dwError = GetLastError();
198201
LogError(LOG_TAG
199-
"CalculateFileSha256.CryptBinaryToStringA (conversion) failed. Error: %u",
202+
"CalculateFileSha256.CryptBinaryToStringA (conversion) failed. "
203+
"Error: %u",
200204
dwError);
201205
CryptDestroyHash(hHash);
202206
CryptReleaseContext(hProv, 0);
@@ -286,9 +290,9 @@ HMODULE VerifyAndLoadAnalyticsLibrary(
286290
if (calculated_hash == expected_hash) {
287291
hash_matched = true;
288292
break;
289-
}
290-
else {
291-
LogDebug(LOG_TAG "Hash mismatch: got %s expected %s", calculated_hash.c_str(), expected_hash.c_str());
293+
} else {
294+
LogDebug(LOG_TAG "Hash mismatch: got %s expected %s",
295+
calculated_hash.c_str(), expected_hash.c_str());
292296
}
293297
}
294298

0 commit comments

Comments
 (0)