[Analyzers][CPP]Changes to fix warning 26493 on src/common (#23467)

* Changes to fix warning 26493 on src/common

It will be multi PR change. This does not turn on the rule but fix the code under src/commom

* int cast
This commit is contained in:
sosssego
2023-02-08 11:00:19 +00:00
committed by GitHub
parent 956eb98125
commit a743e496c5
19 changed files with 66 additions and 69 deletions

View File

@@ -247,7 +247,7 @@ namespace PowerToysSettings
bool Settings::serialize_to_buffer(wchar_t* buffer, int* buffer_size)
{
auto result = m_json.Stringify();
const int result_len = (int)result.size() + 1;
const int result_len = static_cast<int>(result.size() + 1);
if (buffer == nullptr || *buffer_size < result_len)
{

View File

@@ -220,7 +220,7 @@ namespace PowerToysSettings
std::array<BYTE, 256> key_states{}; // Zero-initialize
std::array<wchar_t, 256> output;
const UINT wFlags = 1 << 2; // If bit 2 is set, keyboard state is not changed (Windows 10, version 1607 and newer)
auto output_bytes = ToUnicodeEx(key_code, scan_code, key_states.data(), output.data(), (int)output.size() - 1, wFlags, layout);
auto output_bytes = ToUnicodeEx(key_code, scan_code, key_states.data(), output.data(), static_cast<int>(output.size()) - 1, wFlags, layout);
if (output_bytes <= 0)
{
// If ToUnicodeEx fails (e.g. for F1-F12 keys) use GetKeyNameTextW