Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroAir committed Oct 27, 2024
1 parent 369e68c commit 70d9c9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
68 changes: 29 additions & 39 deletions src/Infrastructure/System/Cpu.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "Cpu.h"
#include "Os.h"

#include <cstdlib>
#include <fstream>
#include <sstream>
#include <vector>

Check failure on line 6 in src/Infrastructure/System/Cpu.cc

View workflow job for this annotation

GitHub Actions / Format Check

code should be clang-formatted [-Wclang-format-violations]


#ifdef _WIN32
// clang-format off
#include <windows.h>
Expand Down Expand Up @@ -118,16 +118,15 @@ auto getCurrentCpuTemperature() -> float {
}

// Initialize security.
hres = CoInitializeSecurity(
NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE,
NULL);
hres = CoInitializeSecurity(NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE,
NULL);

if (FAILED(hres)) {
spdlog::error("Failed to initialize security. Error code = {}", hres);
Expand All @@ -136,31 +135,23 @@ auto getCurrentCpuTemperature() -> float {
}

// Obtain the initial locator to WMI.
IWbemLocator *pLoc = NULL;
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *)&pLoc);
IWbemLocator* pLoc = NULL;
hres = CoCreateInstance(CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator,
(LPVOID*) &pLoc);

if (FAILED(hres)) {
spdlog::error("Failed to create IWbemLocator object. Error code = {}", hres);
CoUninitialize();
return temperature;
}

IWbemServices *pSvc = NULL;
IWbemServices* pSvc = NULL;

// Connect to the root\cimv2 namespace with the current user.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"),
NULL,
NULL,
0,
NULL,
0,
0,
&pSvc);
hres = pLoc->ConnectServer(_bstr_t(L"ROOT\\CIMV2"), NULL, NULL, 0, NULL, 0, 0, &pSvc);

if (FAILED(hres)) {
spdlog::error("Could not connect. Error code = {}", hres);
Expand All @@ -170,15 +161,14 @@ auto getCurrentCpuTemperature() -> float {
}

// Set security levels on the proxy.
hres = CoSetProxyBlanket(
pSvc,
RPC_C_AUTHN_WINNT,
RPC_C_AUTHZ_NONE,
NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE);
hres = CoSetProxyBlanket(pSvc,
RPC_C_AUTHN_WINNT,
RPC_C_AUTHZ_NONE,
NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE);

if (FAILED(hres)) {
spdlog::error("Could not set proxy blanket. Error code = {}", hres);
Expand All @@ -189,7 +179,7 @@ auto getCurrentCpuTemperature() -> float {
}

// Use the IWbemServices pointer to make requests of WMI.
IEnumWbemClassObject *pEnumerator = NULL;
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation"),
Expand All @@ -205,7 +195,7 @@ auto getCurrentCpuTemperature() -> float {
return temperature;
}

IWbemClassObject *pclsObj = NULL;
IWbemClassObject* pclsObj = NULL;
ULONG uReturn = 0;

while (pEnumerator) {
Expand All @@ -218,7 +208,7 @@ auto getCurrentCpuTemperature() -> float {
VARIANT vtProp;
hr = pclsObj->Get(L"Temperature", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr) && (vtProp.vt == VT_I4)) {
temperature = static_cast<float>(vtProp.intVal) / 10.0F; // Adjust if necessary
temperature = static_cast<float>(vtProp.intVal) / 10.0F; // Adjust if necessary
}
VariantClear(&vtProp);
pclsObj->Release();
Expand Down
1 change: 0 additions & 1 deletion src/Infrastructure/System/Crash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sstream>
#include <unordered_map>


#ifndef _MSC_VER
#include <unistd.h>
#endif
Expand Down

0 comments on commit 70d9c9a

Please sign in to comment.