mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Analyzers][CPP]Changes to fix warning 26493 on src/runner (#23672)
* Changes to fix warning 26493 on src/runner * formating
This commit is contained in:
parent
49b2823056
commit
9168f871af
@ -75,7 +75,7 @@ bool create_auto_start_task_for_this_user(bool runElevated)
|
|||||||
NULL,
|
NULL,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
IID_ITaskService,
|
IID_ITaskService,
|
||||||
(void**)&pService);
|
reinterpret_cast<void**>(&pService));
|
||||||
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
|
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
|
||||||
|
|
||||||
// Connect to the task service.
|
// Connect to the task service.
|
||||||
@ -286,7 +286,7 @@ bool delete_auto_start_task_for_this_user()
|
|||||||
NULL,
|
NULL,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
IID_ITaskService,
|
IID_ITaskService,
|
||||||
(void**)&pService);
|
reinterpret_cast<void**>(&pService));
|
||||||
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
|
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
|
||||||
|
|
||||||
// Connect to the task service.
|
// Connect to the task service.
|
||||||
@ -351,7 +351,7 @@ bool is_auto_start_task_active_for_this_user()
|
|||||||
NULL,
|
NULL,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
IID_ITaskService,
|
IID_ITaskService,
|
||||||
(void**)&pService);
|
reinterpret_cast<void**>(&pService));
|
||||||
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
|
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
|
||||||
|
|
||||||
// Connect to the task service.
|
// Connect to the task service.
|
||||||
|
@ -48,7 +48,7 @@ void send()
|
|||||||
{
|
{
|
||||||
powertoy->send_settings_telemetry();
|
powertoy->send_settings_telemetry();
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Logger::error(L"Failed to send telemetry for {} module", name);
|
Logger::error(L"Failed to send telemetry for {} module", name);
|
||||||
}
|
}
|
||||||
@ -59,20 +59,20 @@ void send()
|
|||||||
void run_interval()
|
void run_interval()
|
||||||
{
|
{
|
||||||
auto time = get_last_send_time();
|
auto time = get_last_send_time();
|
||||||
long long wait_time = 24*3600;
|
long long wait_time = 24 * 3600;
|
||||||
long long left_to_wait = 0;
|
long long left_to_wait = 0;
|
||||||
if (time.has_value())
|
if (time.has_value())
|
||||||
{
|
{
|
||||||
left_to_wait = max(0, wait_time - timeutil::diff::in_seconds(timeutil::now(), time.value()));
|
left_to_wait = max(0, wait_time - timeutil::diff::in_seconds(timeutil::now(), time.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Sleep((DWORD)left_to_wait * 1000);
|
Sleep(static_cast<DWORD>(left_to_wait * 1000));
|
||||||
send();
|
send();
|
||||||
update_last_send_time(timeutil::now());
|
update_last_send_time(timeutil::now());
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Sleep((DWORD)wait_time * 1000);
|
Sleep(static_cast<DWORD>(wait_time * 1000));
|
||||||
send();
|
send();
|
||||||
update_last_send_time(timeutil::now());
|
update_last_send_time(timeutil::now());
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ void settings_telemetry::init()
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Logger::error("Failed to send settings telemetry");
|
Logger::error("Failed to send settings telemetry");
|
||||||
}
|
}
|
||||||
}).detach();
|
}).detach();
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ void dispatch_received_json(const std::wstring& json_to_parse)
|
|||||||
|
|
||||||
void dispatch_received_json_callback(PVOID data)
|
void dispatch_received_json_callback(PVOID data)
|
||||||
{
|
{
|
||||||
std::wstring* msg = (std::wstring*)data;
|
std::wstring* msg = static_cast<std::wstring*>(data);
|
||||||
dispatch_received_json(*msg);
|
dispatch_received_json(*msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
|
|||||||
auto val = get_last_error_message(GetLastError());
|
auto val = get_last_error_message(GetLastError());
|
||||||
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
||||||
}
|
}
|
||||||
else if (UuidToString(&temp_uuid, (RPC_WSTR*)&uuid_chars) != RPC_S_OK)
|
else if (UuidToString(&temp_uuid, reinterpret_cast<RPC_WSTR*>(&uuid_chars)) != RPC_S_OK)
|
||||||
{
|
{
|
||||||
auto val = get_last_error_message(GetLastError());
|
auto val = get_last_error_message(GetLastError());
|
||||||
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
||||||
@ -355,7 +355,7 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
|
|||||||
{
|
{
|
||||||
powertoys_pipe_name += std::wstring(uuid_chars);
|
powertoys_pipe_name += std::wstring(uuid_chars);
|
||||||
settings_pipe_name += std::wstring(uuid_chars);
|
settings_pipe_name += std::wstring(uuid_chars);
|
||||||
RpcStringFree((RPC_WSTR*)&uuid_chars);
|
RpcStringFree(reinterpret_cast<RPC_WSTR*>(&uuid_chars));
|
||||||
uuid_chars = nullptr;
|
uuid_chars = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ bool dispatch_run_on_main_ui_thread(main_loop_callback_function _callback, PVOID
|
|||||||
wnd_msg->_callback = _callback;
|
wnd_msg->_callback = _callback;
|
||||||
wnd_msg->data = data;
|
wnd_msg->data = data;
|
||||||
|
|
||||||
PostMessage(tray_icon_hwnd, wm_run_on_main_ui_thread, 0, (LPARAM)wnd_msg);
|
PostMessage(tray_icon_hwnd, wm_run_on_main_ui_thread, 0, reinterpret_cast<LPARAM>(wnd_msg));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ID_REPORT_BUG_COMMAND:
|
case ID_REPORT_BUG_COMMAND:
|
||||||
{
|
{
|
||||||
std::wstring bug_report_path = get_module_folderpath();
|
std::wstring bug_report_path = get_module_folderpath();
|
||||||
bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
|
bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
|
||||||
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
||||||
@ -116,7 +116,6 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
|
|||||||
RunNonElevatedEx(L"https://aka.ms/PowerToysOverview", L"", L"");
|
RunNonElevatedEx(L"https://aka.ms/PowerToysOverview", L"", L"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +241,7 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
|
|||||||
{
|
{
|
||||||
if (lparam != NULL)
|
if (lparam != NULL)
|
||||||
{
|
{
|
||||||
struct run_on_main_ui_thread_msg* msg = (struct run_on_main_ui_thread_msg*)lparam;
|
struct run_on_main_ui_thread_msg* msg = reinterpret_cast<struct run_on_main_ui_thread_msg*>(lparam);
|
||||||
msg->_callback(msg->data);
|
msg->_callback(msg->data);
|
||||||
delete msg;
|
delete msg;
|
||||||
lparam = NULL;
|
lparam = NULL;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
static IMAGEHLP_SYMBOL64* p_symbol = (IMAGEHLP_SYMBOL64*)malloc(sizeof(IMAGEHLP_SYMBOL64) + MAX_PATH * sizeof(WCHAR));
|
static IMAGEHLP_SYMBOL64* p_symbol = static_cast<IMAGEHLP_SYMBOL64*>(malloc(sizeof(IMAGEHLP_SYMBOL64) + MAX_PATH * sizeof(WCHAR)));
|
||||||
static IMAGEHLP_LINE64 line;
|
static IMAGEHLP_LINE64 line;
|
||||||
static bool processing_exception = false;
|
static bool processing_exception = false;
|
||||||
static WCHAR module_path[MAX_PATH];
|
static WCHAR module_path[MAX_PATH];
|
||||||
@ -106,14 +106,14 @@ void log_stack_trace(std::wstring& generalErrorDescription)
|
|||||||
#else
|
#else
|
||||||
IMAGE_FILE_MACHINE_AMD64,
|
IMAGE_FILE_MACHINE_AMD64,
|
||||||
#endif
|
#endif
|
||||||
process,
|
process,
|
||||||
thread,
|
thread,
|
||||||
&stack,
|
&stack,
|
||||||
&context,
|
&context,
|
||||||
NULL,
|
NULL,
|
||||||
SymFunctionTableAccess64,
|
SymFunctionTableAccess64,
|
||||||
SymGetModuleBase64,
|
SymGetModuleBase64,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
p_symbol->MaxNameLength = MAX_PATH;
|
p_symbol->MaxNameLength = MAX_PATH;
|
||||||
p_symbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
|
p_symbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
|
||||||
@ -126,7 +126,7 @@ void log_stack_trace(std::wstring& generalErrorDescription)
|
|||||||
auto module_base = SymGetModuleBase64(process, stack.AddrPC.Offset);
|
auto module_base = SymGetModuleBase64(process, stack.AddrPC.Offset);
|
||||||
if (module_base)
|
if (module_base)
|
||||||
{
|
{
|
||||||
GetModuleFileName((HINSTANCE)module_base, module_path, MAX_PATH);
|
GetModuleFileName(reinterpret_cast<HINSTANCE>(module_base), module_path, MAX_PATH);
|
||||||
}
|
}
|
||||||
ss << module_path << "!"
|
ss << module_path << "!"
|
||||||
<< p_symbol->Name
|
<< p_symbol->Name
|
||||||
|
Loading…
Reference in New Issue
Block a user