[Analyzers][CPP]Turn on C26495 and fix code (#21163)

C26495: A member variable isn't initialized by a constructor or by an initializer.
Fixing occurrences with default member initialization.
This commit is contained in:
sosssego
2022-10-18 15:21:18 +01:00
committed by GitHub
parent 17b80aa0f1
commit 16c28c788d
11 changed files with 47 additions and 43 deletions

View File

@@ -22,7 +22,7 @@
<Rule Id="C26454" Action="Info" /> <Rule Id="C26454" Action="Info" />
<Rule Id="C26478" Action="Info" /> <Rule Id="C26478" Action="Info" />
<Rule Id="C26479" Action="Info" /> <Rule Id="C26479" Action="Info" />
<Rule Id="C26495" Action="Info" /> <Rule Id="C26495" Action="Error" />
<Rule Id="C26498" Action="Info" /> <Rule Id="C26498" Action="Info" />
<Rule Id="C26800" Action="Info" /> <Rule Id="C26800" Action="Info" />
<Rule Id="C26810" Action="Info" /> <Rule Id="C26810" Action="Info" />

View File

@@ -35,7 +35,7 @@ class D3DCaptureState final
winrt::IDirect3DDevice device; winrt::IDirect3DDevice device;
winrt::com_ptr<IDXGISwapChain1> swapChain; winrt::com_ptr<IDXGISwapChain1> swapChain;
winrt::SizeInt32 frameSize; winrt::SizeInt32 frameSize{};
HMONITOR monitor = {}; HMONITOR monitor = {};
winrt::DirectXPixelFormat pixelFormat; winrt::DirectXPixelFormat pixelFormat;

View File

@@ -49,7 +49,8 @@ protected:
bool hidden = true; bool hidden = true;
bool initialized = false; bool initialized = false;
HWND hwnd; HWND hwnd;
UINT window_width, window_height; UINT window_width{};
UINT window_height{};
winrt::com_ptr<ID3D11Device> d3d_device; winrt::com_ptr<ID3D11Device> d3d_device;
winrt::com_ptr<IDXGIDevice> dxgi_device; winrt::com_ptr<IDXGIDevice> dxgi_device;
winrt::com_ptr<IDXGIFactory2> dxgi_factory; winrt::com_ptr<IDXGIFactory2> dxgi_factory;

View File

@@ -58,7 +58,7 @@ private:
static inline PCWSTR name = L"overlay_opacity"; static inline PCWSTR name = L"overlay_opacity";
int value; int value;
int resourceId = IDS_SETTING_DESCRIPTION_OVERLAY_OPACITY; int resourceId = IDS_SETTING_DESCRIPTION_OVERLAY_OPACITY;
} overlayOpacity; } overlayOpacity{};
struct Theme struct Theme
{ {

View File

@@ -8,7 +8,11 @@
struct TasklistButton struct TasklistButton
{ {
std::wstring name; std::wstring name;
long x, y, width, height, keynum; long x{};
long y{};
long width{};
long height{};
long keynum{};
}; };
class Tasklist class Tasklist

View File

@@ -25,15 +25,15 @@ namespace JsonUtils
std::wstring monitorName; std::wstring monitorName;
std::wstring monitorInstanceId; std::wstring monitorInstanceId;
std::wstring monitorSerialNumber; std::wstring monitorSerialNumber;
int monitorNumber; int monitorNumber{};
std::wstring virtualDesktop; std::wstring virtualDesktop;
int dpi; int dpi{};
int top; int top{};
int left; int left{};
int workAreaWidth; int workAreaWidth{};
int workAreaHeight; int workAreaHeight{};
int monitorWidth; int monitorWidth{};
int monitorHeight; int monitorHeight{};
bool isSelected = false; bool isSelected = false;
static json::JsonObject ToJson(const MonitorInfo& monitor) static json::JsonObject ToJson(const MonitorInfo& monitor)
@@ -60,8 +60,8 @@ namespace JsonUtils
struct EditorArgs struct EditorArgs
{ {
DWORD processId; DWORD processId{};
bool spanZonesAcrossMonitors; bool spanZonesAcrossMonitors{};
std::vector<MonitorInfo> monitors; std::vector<MonitorInfo> monitors;
static json::JsonObject ToJson(const EditorArgs& args) static json::JsonObject ToJson(const EditorArgs& args)

View File

@@ -102,7 +102,7 @@ namespace JsonUtils
struct CustomLayoutJSON struct CustomLayoutJSON
{ {
GUID layoutId; GUID layoutId{};
FancyZonesDataTypes::CustomLayoutData data; FancyZonesDataTypes::CustomLayoutData data;
static std::optional<CustomLayoutJSON> FromJson(const json::JsonObject& json) static std::optional<CustomLayoutJSON> FromJson(const json::JsonObject& json)

View File

@@ -36,8 +36,8 @@ namespace FancyZonesDataTypes
struct CanvasLayoutInfo struct CanvasLayoutInfo
{ {
int lastWorkAreaWidth; int lastWorkAreaWidth{};
int lastWorkAreaHeight; int lastWorkAreaHeight{};
struct Rect struct Rect
{ {
@@ -47,7 +47,7 @@ namespace FancyZonesDataTypes
int height; int height;
}; };
std::vector<CanvasLayoutInfo::Rect> zones; std::vector<CanvasLayoutInfo::Rect> zones;
int sensitivityRadius; int sensitivityRadius{};
}; };
struct GridLayoutInfo struct GridLayoutInfo
@@ -95,29 +95,29 @@ namespace FancyZonesDataTypes
std::vector<int> m_rowsPercents; std::vector<int> m_rowsPercents;
std::vector<int> m_columnsPercents; std::vector<int> m_columnsPercents;
std::vector<std::vector<int>> m_cellChildMap; std::vector<std::vector<int>> m_cellChildMap;
bool m_showSpacing; bool m_showSpacing{};
int m_spacing; int m_spacing{};
int m_sensitivityRadius; int m_sensitivityRadius{};
}; };
struct CustomLayoutData struct CustomLayoutData
{ {
std::wstring name; std::wstring name;
CustomLayoutType type; CustomLayoutType type{};
std::variant<CanvasLayoutInfo, GridLayoutInfo> info; std::variant<CanvasLayoutInfo, GridLayoutInfo> info;
}; };
struct ZoneSetData struct ZoneSetData
{ {
std::wstring uuid; std::wstring uuid;
ZoneSetLayoutType type; ZoneSetLayoutType type{};
}; };
struct DeviceId struct DeviceId
{ {
std::wstring id; std::wstring id;
std::wstring instanceId; std::wstring instanceId;
int number; int number{};
bool isDefault() const noexcept; bool isDefault() const noexcept;
std::wstring toString() const noexcept; std::wstring toString() const noexcept;
@@ -125,7 +125,7 @@ namespace FancyZonesDataTypes
struct MonitorId struct MonitorId
{ {
HMONITOR monitor; HMONITOR monitor{};
DeviceId deviceId; DeviceId deviceId;
std::wstring serialNumber; std::wstring serialNumber;
@@ -135,7 +135,7 @@ namespace FancyZonesDataTypes
struct WorkAreaId struct WorkAreaId
{ {
MonitorId monitorId; MonitorId monitorId;
GUID virtualDesktopId; GUID virtualDesktopId{};
std::wstring toString() const noexcept; std::wstring toString() const noexcept;
}; };
@@ -152,10 +152,10 @@ namespace FancyZonesDataTypes
struct DeviceInfoData struct DeviceInfoData
{ {
ZoneSetData activeZoneSet; ZoneSetData activeZoneSet;
bool showSpacing; bool showSpacing{};
int spacing; int spacing{};
int zoneCount; int zoneCount{};
int sensitivityRadius; int sensitivityRadius{};
}; };
inline bool operator==(const ZoneSetData& lhs, const ZoneSetData& rhs) inline bool operator==(const ZoneSetData& lhs, const ZoneSetData& rhs)

View File

@@ -13,9 +13,9 @@ namespace BackwardsCompatibility
struct DeviceIdData struct DeviceIdData
{ {
std::wstring deviceName = L"FallbackDevice"; std::wstring deviceName = L"FallbackDevice";
int width; int width{};
int height; int height{};
GUID virtualDesktopId; GUID virtualDesktopId{};
std::wstring monitorId; std::wstring monitorId;
static std::optional<DeviceIdData> ParseDeviceId(const std::wstring& str); static std::optional<DeviceIdData> ParseDeviceId(const std::wstring& str);
@@ -77,7 +77,7 @@ namespace JSONHelpers
struct LayoutQuickKeyJSON struct LayoutQuickKeyJSON
{ {
std::wstring layoutUuid; std::wstring layoutUuid;
int key; int key{};
static std::optional<LayoutQuickKeyJSON> FromJson(const json::JsonObject& device); static std::optional<LayoutQuickKeyJSON> FromJson(const json::JsonObject& device);
}; };

View File

@@ -40,17 +40,16 @@ namespace winrt::PowerRenameUI::implementation
private: private:
std::wstring StateToErrorMessage(); std::wstring StateToErrorMessage();
int32_t m_id; int32_t m_id{};
hstring m_idStr; hstring m_idStr;
winrt::hstring m_original; winrt::hstring m_original;
winrt::hstring m_renamed; winrt::hstring m_renamed;
uint32_t m_depth; uint32_t m_depth{};
hstring m_imagePath; hstring m_imagePath;
int32_t m_type; int32_t m_type{};
bool m_checked; bool m_checked{};
PowerRenameItemRenameStatus m_state; PowerRenameItemRenameStatus m_state{};
winrt::event<Microsoft::UI::Xaml::Data::PropertyChangedEventHandler> m_propertyChanged; winrt::event<Microsoft::UI::Xaml::Data::PropertyChangedEventHandler> m_propertyChanged;
}; };
} }

View File

@@ -56,9 +56,9 @@ private:
bool HideToolbarWhenUnmuted = true; bool HideToolbarWhenUnmuted = true;
uint64_t lastTimeCamOrMicMuteStateChanged; uint64_t lastTimeCamOrMicMuteStateChanged{};
std::atomic_bool moduleSettingsUpdateScheduled = false; std::atomic_bool moduleSettingsUpdateScheduled = false;
std::atomic_bool generalSettingsUpdateScheduled = false; std::atomic_bool generalSettingsUpdateScheduled = false;
UINT_PTR nTimerId; UINT_PTR nTimerId{};
}; };