[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 47 additions and 43 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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