diff --git a/src/runner/auto_start_helper.cpp b/src/runner/auto_start_helper.cpp index e72fa31d78..ebe39d01be 100644 --- a/src/runner/auto_start_helper.cpp +++ b/src/runner/auto_start_helper.cpp @@ -75,7 +75,7 @@ bool create_auto_start_task_for_this_user(bool runElevated) NULL, CLSCTX_INPROC_SERVER, IID_ITaskService, - (void**)&pService); + reinterpret_cast(&pService)); ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr); // Connect to the task service. @@ -286,7 +286,7 @@ bool delete_auto_start_task_for_this_user() NULL, CLSCTX_INPROC_SERVER, IID_ITaskService, - (void**)&pService); + reinterpret_cast(&pService)); ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr); // Connect to the task service. @@ -351,7 +351,7 @@ bool is_auto_start_task_active_for_this_user() NULL, CLSCTX_INPROC_SERVER, IID_ITaskService, - (void**)&pService); + reinterpret_cast(&pService)); ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr); // Connect to the task service. diff --git a/src/runner/settings_telemetry.cpp b/src/runner/settings_telemetry.cpp index 3ef22a9c7a..7bab24d448 100644 --- a/src/runner/settings_telemetry.cpp +++ b/src/runner/settings_telemetry.cpp @@ -48,7 +48,7 @@ void send() { powertoy->send_settings_telemetry(); } - catch(...) + catch (...) { Logger::error(L"Failed to send telemetry for {} module", name); } @@ -59,20 +59,20 @@ void send() void run_interval() { auto time = get_last_send_time(); - long long wait_time = 24*3600; + long long wait_time = 24 * 3600; long long left_to_wait = 0; if (time.has_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(left_to_wait * 1000)); send(); update_last_send_time(timeutil::now()); while (true) { - Sleep((DWORD)wait_time * 1000); + Sleep(static_cast(wait_time * 1000)); send(); update_last_send_time(timeutil::now()); } @@ -87,7 +87,7 @@ void settings_telemetry::init() } catch (...) { - Logger::error("Failed to send settings telemetry"); + Logger::error("Failed to send settings telemetry"); } }).detach(); } diff --git a/src/runner/settings_window.cpp b/src/runner/settings_window.cpp index 5b65693083..06f853713d 100644 --- a/src/runner/settings_window.cpp +++ b/src/runner/settings_window.cpp @@ -242,7 +242,7 @@ void dispatch_received_json(const std::wstring& json_to_parse) void dispatch_received_json_callback(PVOID data) { - std::wstring* msg = (std::wstring*)data; + std::wstring* msg = static_cast(data); dispatch_received_json(*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()); 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(&uuid_chars)) != RPC_S_OK) { auto val = get_last_error_message(GetLastError()); 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); settings_pipe_name += std::wstring(uuid_chars); - RpcStringFree((RPC_WSTR*)&uuid_chars); + RpcStringFree(reinterpret_cast(&uuid_chars)); uuid_chars = nullptr; } diff --git a/src/runner/tray_icon.cpp b/src/runner/tray_icon.cpp index d29527bc72..60669f7d7c 100644 --- a/src/runner/tray_icon.cpp +++ b/src/runner/tray_icon.cpp @@ -53,7 +53,7 @@ bool dispatch_run_on_main_ui_thread(main_loop_callback_function _callback, PVOID wnd_msg->_callback = _callback; 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(wnd_msg)); return true; } @@ -93,7 +93,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam) } break; case ID_REPORT_BUG_COMMAND: - { + { std::wstring bug_report_path = get_module_folderpath(); bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe"; 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""); break; } - } } @@ -242,7 +241,7 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam { 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(lparam); msg->_callback(msg->data); delete msg; lparam = NULL; diff --git a/src/runner/unhandled_exception_handler.cpp b/src/runner/unhandled_exception_handler.cpp index 373d33ea36..1d01349dd3 100644 --- a/src/runner/unhandled_exception_handler.cpp +++ b/src/runner/unhandled_exception_handler.cpp @@ -7,7 +7,7 @@ #include #include -static IMAGEHLP_SYMBOL64* p_symbol = (IMAGEHLP_SYMBOL64*)malloc(sizeof(IMAGEHLP_SYMBOL64) + MAX_PATH * sizeof(WCHAR)); +static IMAGEHLP_SYMBOL64* p_symbol = static_cast(malloc(sizeof(IMAGEHLP_SYMBOL64) + MAX_PATH * sizeof(WCHAR))); static IMAGEHLP_LINE64 line; static bool processing_exception = false; static WCHAR module_path[MAX_PATH]; @@ -106,14 +106,14 @@ void log_stack_trace(std::wstring& generalErrorDescription) #else IMAGE_FILE_MACHINE_AMD64, #endif - process, - thread, - &stack, - &context, - NULL, - SymFunctionTableAccess64, - SymGetModuleBase64, - NULL); + process, + thread, + &stack, + &context, + NULL, + SymFunctionTableAccess64, + SymGetModuleBase64, + NULL); p_symbol->MaxNameLength = MAX_PATH; 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); if (module_base) { - GetModuleFileName((HINSTANCE)module_base, module_path, MAX_PATH); + GetModuleFileName(reinterpret_cast(module_base), module_path, MAX_PATH); } ss << module_path << "!" << p_symbol->Name