From: lx-s Date: Tue, 19 Dec 2023 06:43:57 +0000 (+0100) Subject: Fixed some analyzer warnings X-Git-Tag: 2.4.9.0~33 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=db175282d50beedaf3fd352f15dcdc8898cf99a1;p=winmute.git Fixed some analyzer warnings --- diff --git a/WinMute/AboutDlg.cpp b/WinMute/AboutDlg.cpp index 87d5fa4..bc2bb77 100644 --- a/WinMute/AboutDlg.cpp +++ b/WinMute/AboutDlg.cpp @@ -180,7 +180,11 @@ static INT_PTR CALLBACK About_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM, LPARAM return TRUE; case WM_NOTIFY: { const PNMLINK pNmLink = reinterpret_cast(lParam); - if (pNmLink->hdr.code == NM_CLICK || pNmLink->hdr.code == NM_RETURN) { +#pragma warning(push) +#pragma warning(disable : 26454) // Disable arithmetic overflow warning for NM_CLICK and NM_RETURN + if (pNmLink->hdr.code == NM_CLICK || + pNmLink->hdr.code == NM_RETURN) { +#pragma warning(pop) const UINT_PTR ctrlId = pNmLink->hdr.idFrom; const LITEM item = pNmLink->item; if ((ctrlId == IDC_LINK_HOMEPAGE @@ -296,8 +300,10 @@ INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) } case WM_NOTIFY: { const LPNMHDR lpnmhdr = reinterpret_cast(lParam); - if (lpnmhdr->code == TCN_SELCHANGE - && lpnmhdr->hwndFrom == dlgData->hTabCtrl) { +#pragma warning(push) +#pragma warning(disable : 26454) // Disable arithmetic overflow for TCN_SELCHANGE + if (lpnmhdr->code == TCN_SELCHANGE && lpnmhdr->hwndFrom == dlgData->hTabCtrl) { +#pragma warning(pop) const int curSel = TabCtrl_GetCurSel(dlgData->hTabCtrl); if (curSel >= 0 && curSel < ABOUT_TAB_COUNT) { SwitchTab(dlgData, dlgData->hTabs[curSel]); diff --git a/WinMute/BluetoothDetector.cpp b/WinMute/BluetoothDetector.cpp index 7991162..580e47c 100644 --- a/WinMute/BluetoothDetector.cpp +++ b/WinMute/BluetoothDetector.cpp @@ -158,7 +158,7 @@ BluetoothDetector::BluetoothStatus BluetoothDetector::GetBluetoothStatus( if (useDeviceList_) { auto pos = std::find(begin(deviceNames_), end(deviceNames_), inRangeInfo->deviceInfo.name); if (pos == end(deviceNames_)) { - log.Write(L"Bluetooth device \"S\" not in list.", inRangeInfo->deviceInfo.name); + log.Write(L"Bluetooth device \"%S\" not in list.", inRangeInfo->deviceInfo.name); return BluetoothStatus::Unknown; } } diff --git a/WinMute/MMNotificationClient.cpp b/WinMute/MMNotificationClient.cpp index 31c8740..529f175 100644 --- a/WinMute/MMNotificationClient.cpp +++ b/WinMute/MMNotificationClient.cpp @@ -90,7 +90,7 @@ HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceAdded(LPCWSTR pwstrDevic { if (notifyParent_ && pwstrDeviceId != nullptr) { const auto deviceName = GetFriendlyDeviceName(pwstrDeviceId); - WMLog::GetInstance().GetInstance().Write(L"Device \"%S\" added", deviceName.c_str()); + WMLog::GetInstance().GetInstance().Write(L"Device \"%s\" added", deviceName.c_str()); notifyParent_->ShouldReInit(); } return S_OK; @@ -100,7 +100,7 @@ HRESULT STDMETHODCALLTYPE MMNotificationClient::OnDeviceRemoved(LPCWSTR pwstrDev { if (notifyParent_ && pwstrDeviceId != nullptr) { const auto deviceName = GetFriendlyDeviceName(pwstrDeviceId); - WMLog::GetInstance().GetInstance().Write(L"Device \"%S\" removed", deviceName.c_str()); + WMLog::GetInstance().GetInstance().Write(L"Device \"%s\" removed", deviceName.c_str()); notifyParent_->ShouldReInit(); } return S_OK; diff --git a/WinMute/SettingsDlg.cpp b/WinMute/SettingsDlg.cpp index e813552..4e9eb77 100644 --- a/WinMute/SettingsDlg.cpp +++ b/WinMute/SettingsDlg.cpp @@ -220,8 +220,10 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar return 0; case WM_NOTIFY: { const LPNMHDR lpnmhdr = reinterpret_cast(lParam); - if (lpnmhdr->code == TCN_SELCHANGE - && lpnmhdr->hwndFrom == dlgData->hTabCtrl) { +#pragma warning(push) +#pragma warning(disable : 26454) // Disable arithmetic overflow warning for TCN_SELCHANGE + if (lpnmhdr->code == TCN_SELCHANGE && lpnmhdr->hwndFrom == dlgData->hTabCtrl) { +#pragma warning(pop) const int curSel = TabCtrl_GetCurSel(dlgData->hTabCtrl); if (curSel >= 0 && curSel < SETTINGS_TAB_COUNT) { SwitchTab(dlgData, dlgData->hTabs[curSel]); diff --git a/WinMute/WMLog.cpp b/WinMute/WMLog.cpp index be90b75..9e15a07 100644 --- a/WinMute/WMLog.cpp +++ b/WinMute/WMLog.cpp @@ -118,7 +118,7 @@ void WMLog::WriteMessage(const wchar_t* msg) logFile_.flush(); } -void WMLog::Write(const wchar_t *fmt, ...) +void WMLog::Write(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) { if (!enabled_) { return; diff --git a/WinMute/WMLog.h b/WinMute/WMLog.h index 08c0229..3d56c14 100644 --- a/WinMute/WMLog.h +++ b/WinMute/WMLog.h @@ -39,7 +39,7 @@ class WMLog { public: static WMLog& GetInstance(); - void Write(const wchar_t* fmt, ...); + void Write(_In_z_ _Printf_format_string_ const wchar_t* fmt, ...); void WriteWindowsError(const wchar_t *functionName, DWORD errorCode = -1); void SetEnabled(bool enable); diff --git a/WinMute/WMi18n.cpp b/WinMute/WMi18n.cpp index 8a6b3d2..3a68f19 100644 --- a/WinMute/WMi18n.cpp +++ b/WinMute/WMi18n.cpp @@ -119,7 +119,7 @@ std::vector WMi18n::GetAvailableLanguages() const langDlls.push_back(langMod); } } catch (const nlohmann::json::parse_error &pe) { - WMLog::GetInstance().Write(L"Failed to parse language file \"%ls\": %s", wfd.cFileName, pe.what()); + WMLog::GetInstance().Write(L"Failed to parse language file \"%ls\": %S", wfd.cFileName, pe.what()); } } while (FindNextFileW(hFindFile, &wfd)); } @@ -179,11 +179,11 @@ bool WMi18n::LoadLanguage(const std::wstring &fileName, TranslationMap &strings) } const auto value = ConvertStringToWideString(it.value()); if (value == L"") { - log.Write(L"Unable to convert language element \"%s\"", it.key().c_str()); + log.Write(L"Unable to convert language element \"%S\"", it.key().c_str()); return false; } if (translations_temp.contains(it.key())) { - log.Write(L"Double entry for language key \"%s\" found.", it.key().c_str()); + log.Write(L"Double entry for language key \"%S\" found.", it.key().c_str()); return false; } translations_temp[it.key()] = value; @@ -191,7 +191,7 @@ bool WMi18n::LoadLanguage(const std::wstring &fileName, TranslationMap &strings) strings = std::move(translations_temp); } catch (const nlohmann::json::parse_error &pe) { WMLog::GetInstance().Write( - L"Failed to parse language file \"%ls\": %s", + L"Failed to parse language file \"%ls\": %S", langFilePath->filename().c_str(), pe.what()); return false; diff --git a/WinMute/common.h b/WinMute/common.h index eb2d327..57f6da8 100644 --- a/WinMute/common.h +++ b/WinMute/common.h @@ -94,6 +94,7 @@ namespace fs = std::filesystem; #include #include #include +#include #pragma warning(disable : 4201) # include #pragma warning(default : 4201) diff --git a/WinMute/libs/json.hpp b/WinMute/libs/json.hpp index 8b72ea6..4d4c89c 100644 --- a/WinMute/libs/json.hpp +++ b/WinMute/libs/json.hpp @@ -8235,7 +8235,7 @@ class lexer : public lexer_base } } } - + [[fallthrough]]; // multi-line comments skip input until */ is read case '*': { @@ -8269,8 +8269,9 @@ class lexer : public lexer_base continue; } } + [[fallthrough]]; } - + // unexpected character after reading '/' default: {