Resolve C26495 Prefast Issues on Foundation (#4363)

This commit is contained in:
Kyaw Thant 2024-04-25 00:39:58 -07:00 коммит произвёл GitHub
Родитель 7d27cb4ead
Коммит 1ed3fb1b00
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
11 изменённых файлов: 32 добавлений и 32 удалений

Просмотреть файл

@ -72,7 +72,7 @@ steps:
- ${{ if eq(parameters.runStaticAnalysis, 'True') }}:
- task: SDLNativeRules@3
displayName: Run PREfast SDL Native Rules
displayName: Run PREfast SDL Native Rules
condition: and(succeeded(), eq(variables['buildConfiguration'], 'Release'), eq(variables['buildPlatform'], 'x64'))
inputs:
setupCommandlines: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsMSBuildCmd.bat"'
@ -92,6 +92,7 @@ steps:
contents: |
**
!**\*test*\**
!**\*packages*\**
!**\*Demoapp*\**
!**\*Demopackage\**
!**\*.json

Просмотреть файл

@ -29,9 +29,8 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation
protected:
ActivatedEventArgsBase() = default;
ActivationKind m_kind = ActivationKind::Launch;
ApplicationExecutionState m_previousState;
ActivationKind m_kind{ ActivationKind::Launch };
ApplicationExecutionState m_previousState{ ApplicationExecutionState::NotRunning };
winrt::Windows::ApplicationModel::Activation::SplashScreen m_splashScreen{ nullptr };
};
}

Просмотреть файл

@ -83,10 +83,10 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation
winrt::com_ptr<IUnknown> m_site;
winrt::com_ptr<IShellItemArray> m_selection;
std::wstring m_directory;
DWORD m_keyState;
BOOL m_noShowUI;
DWORD m_keyState{ 0 };
BOOL m_noShowUI{ false };
std::wstring m_parameters;
POINT m_pos;
int m_showWindowState;
POINT m_pos{};
int m_showWindowState{ 0 };
};
}

Просмотреть файл

@ -48,7 +48,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
BindMode m_statusBindMode;
winrt::hstring m_status;
BindMode m_valueBindMode;
double m_value;
double m_value{ 0.0 };
BindMode m_valueStringOverrideBindMode;
winrt::hstring m_valueStringOverride;
};

Просмотреть файл

@ -19,10 +19,10 @@ namespace WindowsAppRuntime::Deployment::Activity
struct WilFailure
{
wil::FailureType type;
HRESULT hr;
wil::FailureType type { wil::FailureType::Exception };
HRESULT hr { S_OK };
std::string file;
unsigned int lineNumber;
unsigned int lineNumber{ 0 };
std::wstring message;
std::string module;
};

Просмотреть файл

@ -42,10 +42,10 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Microsoft::Windows::ApplicationModel::DynamicDependency::PackageDependencyContextId PackageDependencyContextId();
private:
hstring m_packageSetItemId;
hstring m_packageFullName;
hstring m_packageDependencyId;
winrt::Microsoft::Windows::ApplicationModel::DynamicDependency::PackageDependencyContextId m_packageDependencyContextId;
hstring m_packageSetItemId{};
hstring m_packageFullName{};
hstring m_packageDependencyId{};
winrt::Microsoft::Windows::ApplicationModel::DynamicDependency::PackageDependencyContextId m_packageDependencyContextId{};
};
}
namespace winrt::Microsoft::Windows::Management::Deployment::factory_implementation

Просмотреть файл

@ -249,7 +249,7 @@ namespace winrt::Microsoft::Windows::System::Power::implementation
// Needs to get a temporary subscription to get most recent value
struct notify_callback {
EFFECTIVE_POWER_MODE mode;
EFFECTIVE_POWER_MODE mode{ EffectivePowerModeBatterySaver };
wil::slim_event done;
} context;

Просмотреть файл

@ -107,21 +107,21 @@ namespace winrt::Microsoft::Windows::System::Power
{
std::mutex m_mutex;
int m_batteryChargePercent{ 100 };
int m_oldBatteryChargePercent;
DWORD m_cachedDisplayStatus;
DWORD m_cachedUserPresenceStatus;
DWORD m_cachedSystemAwayModeStatus;
DWORD m_cachedPowerSourceKind;
EFFECTIVE_POWER_MODE m_cachedPowerMode;
ULONGLONG m_cachedDischargeTime;
int m_oldBatteryChargePercent{ 0 };
DWORD m_cachedDisplayStatus{ 0 };
DWORD m_cachedUserPresenceStatus{ 0 };
DWORD m_cachedSystemAwayModeStatus{ 0 };
DWORD m_cachedPowerSourceKind{ 0 };
EFFECTIVE_POWER_MODE m_cachedPowerMode{ EffectivePowerModeBatterySaver };
ULONGLONG m_cachedDischargeTime{ 0 };
std::atomic<ULONG> m_powerModeVersion;
Power::SystemSuspendStatus m_systemSuspendStatus;
::EnergySaverStatus m_cachedEnergySaverStatus;
Power::SystemSuspendStatus m_systemSuspendStatus{ SystemSuspendStatus::Uninitialized };
::EnergySaverStatus m_cachedEnergySaverStatus{ Uninitalized };
CompositeBatteryStatus m_cachedCompositeBatteryStatus{};
Power::BatteryStatus m_batteryStatus{ Power::BatteryStatus::NotPresent };
Power::BatteryStatus m_oldBatteryStatus;
Power::BatteryStatus m_oldBatteryStatus{ Power::BatteryStatus::NotPresent };
Power::PowerSupplyStatus m_powerSupplyStatus{ Power::PowerSupplyStatus::Adequate };
Power::PowerSupplyStatus m_oldPowerSupplyStatus;
Power::PowerSupplyStatus m_oldPowerSupplyStatus{ Power::PowerSupplyStatus::Adequate };
EventType m_energySaverStatusChangedEvent;
EventType m_batteryStatusChangedEvent;

Просмотреть файл

@ -27,6 +27,6 @@ private:
std::wstring m_appId;
std::wstring m_processName;
winrt::guid m_comServerClsid;
winrt::guid m_comServerClsid{};
wil::srwlock m_lock;
};

Просмотреть файл

@ -32,8 +32,8 @@ struct component
wstring module_name;
wstring xmlns;
HMODULE handle = nullptr;
activation_factory_type get_activation_factory;
ABI::Windows::Foundation::ThreadingType threading_model;
activation_factory_type get_activation_factory{};
ABI::Windows::Foundation::ThreadingType threading_model{ ABI::Windows::Foundation::ThreadingType::ThreadingType_BOTH };
~component()
{

Просмотреть файл

@ -43,7 +43,7 @@ namespace WindowsAppRuntime::MddBootstrap::Activity
wil::unique_cotaskmem_string m_initializationPackageFullName;
WindowsAppRuntimeBootstrap_TraceLogger::Shutdown m_bootstrapShutdownActivity;
GUID m_bootstrapShutdownActivityId{};
WilFailure m_lastFailure;
WilFailure m_lastFailure{};
bool m_stopActivityForWilReturnHR{};
public: