Skip to content

Commit 2bacc12

Browse files
committed
Fixed various minor issues identified through static analysis
1 parent 4d7916e commit 2bacc12

22 files changed

Lines changed: 512 additions & 125 deletions

File tree

SpecialK.suppress

Lines changed: 360 additions & 0 deletions
Large diffs are not rendered by default.

SpecialK.vcxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,9 @@ if exist "$(TargetDir)$(TargetName).exp" ( del "$(TargetDir)$(TargetName).exp" )
20132013
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
20142014
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (clang)|Win32'">true</ExcludedFromBuild>
20152015
</ClCompile>
2016-
<ClCompile Include="src\plugins\ffxvi.cpp" />
2016+
<ClCompile Include="src\plugins\ffxvi.cpp">
2017+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
2018+
</ClCompile>
20172019
<ClCompile Include="src\plugins\lords_of_the_fallen2.cpp" />
20182020
<ClCompile Include="src\plugins\monster_hunter_world.cpp">
20192021
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

include/SpecialK/render/d3d12/d3d12_interfaces.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,6 @@ struct SK_D3D12_StateTransition : D3D12_RESOURCE_BARRIER
507507
{ };
508508
};
509509

510-
class SK_ScopedLock {
511-
public:
512-
SK_ScopedLock (void);
513-
SK_ScopedLock (SK_Thread_HybridSpinlock* lock);
514-
SK_ScopedLock (SK_ScopedLock&& in);
515-
~SK_ScopedLock (void);
516-
517-
protected:
518-
SK_Thread_HybridSpinlock* _lock;
519-
};
520-
521510
struct SK_D3D12_RenderCtx {
522511
struct GPUDuration {
523512
UINT64 Start;
@@ -541,8 +530,6 @@ struct SK_D3D12_RenderCtx {
541530

542531
SK_Thread_HybridSpinlock _ctx_lock;
543532

544-
SK_ScopedLock acquireScopedLock (void) noexcept;
545-
546533
SK_ComPtr <ID3D12Device> _pDevice = nullptr;
547534
SK_ComPtr <ID3D12CommandQueue> _pCommandQueue = nullptr;
548535
SK_ComPtr <IDXGISwapChain3> _pSwapChain = nullptr;

src/config.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6381,10 +6381,10 @@ auto DeclKeybind =
63816381
(SK_Steam_GetAppID_NoAPI () != 0 && config.system.first_run) || SK_IsAdmin ();
63826382

63836383
struct {
6384-
int ver = 0;
6385-
int sub_ver = 0;
6386-
int build = 0;
6387-
int rev = 0;
6384+
unsigned int ver = 0U;
6385+
unsigned int sub_ver = 0U;
6386+
unsigned int build = 0U;
6387+
unsigned int rev = 0U;
63886388
std::wstring str = L"";
63896389
} static unity_dll;
63906390

@@ -8360,7 +8360,8 @@ SK_AppCache_Manager::loadAppCacheForExe (const wchar_t* wszExe)
83608360
mancpn.is_open ())
83618361
{
83628362
char szLine [512] = { };
8363-
while (! mancpn.getline (szLine, 511).eof ())
8363+
while (! mancpn.getline (szLine, 511).eof () &&
8364+
! mancpn.fail () )
83648365
{
83658366
if (StrStrIA (szLine, "\"AppName\"") != nullptr)
83668367
{
@@ -8700,7 +8701,8 @@ SK_AppCache_Manager::getConfigPathFromAppPath (const wchar_t* wszPath) const
87008701
mancpn.is_open ())
87018702
{
87028703
char szLine [512] = { };
8703-
while (! mancpn.getline (szLine, 511).eof ())
8704+
while (! mancpn.getline (szLine, 511).eof () &&
8705+
! mancpn.fail () )
87048706
{
87058707
if (StrStrIA (szLine, "\"AppName\"") != nullptr)
87068708
{

src/diagnostics/compatibility.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,8 @@ SK_COMPAT_WarnIfRTSSIsIncompatible (void)
10081008
auto is_compatible =
10091009
SK_COMPAT_IsRTSSUsingDetoursHooking ();
10101010

1011-
if (is_compatible.has_value () && is_compatible.value () == false)
1011+
if ( is_compatible.has_value () &&
1012+
*is_compatible == false )
10121013
{
10131014
// User only needs 1 warning :)
10141015
SK_RunOnce (

src/imgui/backends/imgui_d3d12.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,9 @@ SK_D3D12_RenderCtx::present (IDXGISwapChain3 *pSwapChain)
27952795
if (_pReShadeRuntime != nullptr)
27962796
{
27972797
_pReShadeRuntime->get_command_queue ()->wait (
2798-
reshade::api::fence { (uint64_t)stagingFrame.fence.p },
2798+
reshade::api::fence { static_cast <uint64_t> (
2799+
reinterpret_cast <uintptr_t> (
2800+
stagingFrame.fence.p ) ) },
27992801
stagingFrame.fence.value
28002802
);
28012803

src/input/cursor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,9 @@ SK_ImGui_WantMouseCapture (bool update, POINT* ptCursor) noexcept
736736

737737
HCURSOR GetGameCursor (void)
738738
{
739+
#if 1
739740
return SK_GetCursor ();
740-
741+
#else // This was the original code, but it tends to permanently change the game's cursor
741742
static HCURSOR sk_imgui_arrow = LoadCursor (SK_GetDLL (), (LPCWSTR)IDC_CURSOR_POINTER);
742743
static HCURSOR sk_imgui_horz = LoadCursor (SK_GetDLL (), (LPCWSTR)IDC_CURSOR_HORZ);
743744
static HCURSOR sk_imgui_ibeam = LoadCursor (nullptr, IDC_IBEAM);
@@ -754,6 +755,7 @@ HCURSOR GetGameCursor (void)
754755
}
755756
756757
return hCurLast;
758+
#endif
757759
}
758760

759761
bool

src/input/dinput8.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@ IDirectInput8W_CreateDevice_Detour ( IDirectInput8W *This,
17211721
hook_lock (hookMutex);
17221722

17231723
std::vector <void *> fns_to_hook;
1724+
fns_to_hook.reserve (3);
17241725

17251726
if (SUCCEEDED (hr) && lplpDirectInputDevice != nullptr &&
17261727
*lplpDirectInputDevice != nullptr)
@@ -1866,6 +1867,7 @@ IDirectInput8A_CreateDevice_Detour ( IDirectInput8A *This,
18661867
hook_lock (hookMutex);
18671868

18681869
std::vector <void *> fns_to_hook;
1870+
fns_to_hook.reserve (3);
18691871

18701872
if (SUCCEEDED (hr) && lplpDirectInputDevice != nullptr &&
18711873
*lplpDirectInputDevice != nullptr)

src/input/hid_reports/playstation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,7 @@ SK_HID_PlayStationDevice::write_output_report (bool force)
31573157

31583158
header.SeqNo++;
31593159

3160-
memcpy (bt_data, &header, sizeof (header));
3160+
memcpy (bt_data, &header, sizeof (header)); //-V1086
31613161

31623162
auto* output =
31633163
(SK_HID_DualSense_SetStateData *)&bt_data [3];
@@ -3783,7 +3783,7 @@ SK_HID_PlayStationDevice::write_output_report (bool force)
37833783
uint8_t EnableAudio : 1;
37843784
} static header = { 0xA2, 0x11, 1, 1, 1, 0, 0, 0, 1, 0, 0 };
37853785

3786-
memcpy (bt_data, &header, sizeof (header));
3786+
memcpy (bt_data, &header, sizeof (header)); //-V1086
37873787

37883788
auto *pOutputRaw =
37893789
&bt_data [4];
@@ -4312,7 +4312,7 @@ bool SK_HID_DeviceFile::filterHidOutput (uint8_t report_id, DWORD dwSize, LPVOID
43124312
uint8_t* packet = &((uint8_t *)data) [i * 78];
43134313

43144314
// Prepend 0xA2 before hashing, this isn't included in the actual data being written...
4315-
uint8_t data_to_checksum [79] = { 0xA2 };
4315+
uint8_t data_to_checksum [79] = { 0xA2 }; //-V1009
43164316
memcpy (&data_to_checksum [ 1], packet, 78);
43174317

43184318
#if 0

src/input/xinput_core.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,10 @@ XInputGetStateEx1_4_Detour (
745745

746746
struct timing_s
747747
{
748-
LONGLONG t0;
749-
LONGLONG tCache;
750-
ULONG64 ulFrame0;
751-
ULONG64 ulCacheFrame;
748+
LONGLONG t0 = 0LL;
749+
LONGLONG tCache = 0LL;
750+
ULONG64 ulFrame0 = 0ULL;
751+
ULONG64 ulCacheFrame = 0ULL;
752752

753753
struct polling_traits_s
754754
{
@@ -845,7 +845,7 @@ XInputGetStateEx1_4_Detour (
845845
if (pState == nullptr)
846846
return ERROR_INVALID_PARAMETER;
847847

848-
RtlZeroMemory (&pState->Gamepad, sizeof (XINPUT_GAMEPAD));
848+
RtlZeroMemory (&pState->Gamepad, sizeof (XINPUT_GAMEPAD)); //-V1086
849849

850850
if (! xinput_enabled)
851851
{
@@ -937,7 +937,7 @@ XInputGetStateEx1_4_Detour (
937937
const auto last_timestamp = ReadULong64Acquire (&hid_to_xi_time);
938938
const auto timestamp = ReadULong64Acquire (&pNewestInputDevice->xinput.last_active);
939939

940-
memcpy (pState, &latest_state, sizeof (XINPUT_STATE));
940+
memcpy (pState, &latest_state, sizeof (XINPUT_STATE)); //-V1086
941941

942942
if ( timestamp> last_timestamp &&
943943
InterlockedCompareExchange (&hid_to_xi_time, timestamp, last_timestamp) == last_timestamp )
@@ -979,7 +979,7 @@ XInputGetStateEx1_4_Detour (
979979
if (SK_ImGui_WantGamepadCapture () || config.input.gamepad.xinput.disable [dwUserIndex])
980980
{
981981
SK_XINPUT_HIDE (dwUserIndex)
982-
ZeroMemory (&pState->Gamepad, sizeof (XINPUT_GAMEPAD));
982+
ZeroMemory (&pState->Gamepad, sizeof (XINPUT_GAMEPAD)); //-V1086
983983
}
984984

985985
else

0 commit comments

Comments
 (0)