Skip to content

Commit

Permalink
Static analysis code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Dec 21, 2024
1 parent b801cf9 commit 34f04c0
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 133 deletions.
16 changes: 16 additions & 0 deletions SpecialK.suppress
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,14 @@
<CodeCurrent>4076215292</CodeCurrent>
<CodeNext>2140692</CodeNext>
</SpecialK>
<SpecialK>
<FileName>opengl.cpp</FileName>
<ErrorCode>V1020</ErrorCode>
<Message>The function exited without calling the 'SK_EndBufferSwap' function. Check lines: _, _.</Message>
<CodePrev>0</CodePrev>
<CodeCurrent>352761</CodeCurrent>
<CodeNext>125</CodeNext>
</SpecialK>
<SpecialK>
<FileName>playstation.cpp</FileName>
<ErrorCode>V512</ErrorCode>
Expand All @@ -633,6 +641,14 @@
<CodeCurrent>3170116418</CodeCurrent>
<CodeNext>17733</CodeNext>
</SpecialK>
<SpecialK>
<FileName>screenshot.cpp</FileName>
<ErrorCode>V512</ErrorCode>
<Message>A call of the 'fwrite' function will lead to overflow of the buffer '&amp; len'.</Message>
<CodePrev>0</CodePrev>
<CodeCurrent>1223074885</CodeCurrent>
<CodeNext>2242012516</CodeNext>
</SpecialK>
<SpecialK>
<FileName>screenshot.h</FileName>
<ErrorCode>V3509</ErrorCode>
Expand Down
2 changes: 1 addition & 1 deletion include/intel/HybridDetect.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace HybridDetect
#endif

// Simple conversion from an ordinal, n, to a set bit at position n
#define IndexToMask(n) (1UL << n)
#define IndexToMask(n) (1UL << (n))

// Macros to store values for CPUID register ordinals
#define CPUID_EAX 0
Expand Down
4 changes: 2 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4618,9 +4618,9 @@ auto DeclKeybind =

input.keyboard.catch_alt_f4->load (config.input.keyboard.catch_alt_f4);
input.keyboard.bypass_alt_f4->load (config.input.keyboard.override_alt_f4);
input.keyboard.disabled_to_game->load (config.input.keyboard.org_disabled_to_game);
input.keyboard.disabled_to_game->load (config.input.keyboard.disabled_to_game);
config.input.keyboard.
org_disabled_to_game= config.input.keyboard.org_disabled_to_game;
org_disabled_to_game= config.input.keyboard.disabled_to_game;

input.mouse.disabled_to_game->load (config.input.mouse.disabled_to_game);
config.input.mouse.
Expand Down
3 changes: 1 addition & 2 deletions src/control_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7270,8 +7270,7 @@ SK_ImGui_MouseProc (int code, WPARAM wParam, LPARAM lParam)
POINT pt (mhs->pt);
ScreenToClient (game_window.hWnd, &pt);
if (ChildWindowFromPointEx (game_window.hWnd, pt, CWP_SKIPDISABLED |
CWP_SKIPINVISIBLE |
CWP_SKIPDISABLED) == game_window.hWnd)
CWP_SKIPINVISIBLE) == game_window.hWnd)
{
bPassthrough = false;

Expand Down
2 changes: 1 addition & 1 deletion src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2339,7 +2339,7 @@ SK_StartupCore (const wchar_t* backend, void* callback)
case SK_GAME_ID::AssassinsCreed_Odyssey:
SK_ACO_PlugInInit ();
break;
case SK_GAME_ID::MonsterHunterWorld:
case SK_GAME_ID::MonsterHunterWorld:
SK_MHW_PlugInInit ();
break;

Expand Down
2 changes: 1 addition & 1 deletion src/ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ __stdcall
iSK_INISection::add_key_value (const std::wstring& key, const std::wstring& value)
{
const auto add =
keys.try_emplace (key, value);
keys.emplace (key, value);

if (add.second)
{
Expand Down
6 changes: 3 additions & 3 deletions src/nvapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,9 @@ NvAPI_Disp_HdrColorControl_Override ( NvU32 displayId,
SK_RenderBackend& rb =
SK_GetCurrentRenderBackend ();

static NV_HDR_COLOR_DATA_V2 expandedData = { };
NV_HDR_COLOR_DATA_V1 *inputData =
(NV_HDR_COLOR_DATA_V1 *)pHdrColorData;
NV_HDR_COLOR_DATA_V2 expandedData = { };
NV_HDR_COLOR_DATA_V1 *inputData =
(NV_HDR_COLOR_DATA_V1 *)pHdrColorData;

if (pHdrColorData->version == NV_HDR_COLOR_DATA_VER1)
{
Expand Down
20 changes: 6 additions & 14 deletions src/osd/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,21 +2090,13 @@ SK_TextOverlay::update (const char* szText)
// Add 1.0 so that an X position of -1.0 is perfectly flush with the right
x = ImGui::GetIO ().DisplaySize.x + x - longest_line + 1.0f;

if (tokenized_text != nullptr)
{
strncpy_s ( tokenized_text, data_.text_len,
data_.text, _TRUNCATE );

// Restart tokenizing
line =
( has_tokens ? strtok_ex (tokenized_text, token)
: tokenized_text );
}
strncpy_s ( tokenized_text, data_.text_len,
data_.text, _TRUNCATE );

else
{
SK_LOGs0 (L"SKTokenize", L"Tokenizer Failure!");
}
// Restart tokenizing
line =
( has_tokens ? strtok_ex (tokenized_text, token)
: tokenized_text );
}

else x += 5.0f; // Fix-up for text off-screen
Expand Down
4 changes: 2 additions & 2 deletions src/render/d3d11/tex_mgr/d3d11_tex_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,8 +1593,8 @@ SK_D3D11_DumpTexture2D ( _In_ const D3D11_TEXTURE2D_DESC *pDesc,

SK_D3D11_AddDumped (top_crc32, checksum);

DirectX::TexMetadata mdata;

DirectX::TexMetadata
mdata = { };
mdata.width = pDesc->Width;
mdata.height = pDesc->Height;
mdata.depth = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/render/d3d12/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct SK_D3D12_ShaderRepo
for (size_t __i = 0; __i < DxilContainerHashSize; ++__i)
{
__h = h.Digest [__i] +
(__h << 06) + (__h << 16)
(__h << 6) + (__h << 16)
- __h;
}

Expand Down Expand Up @@ -3046,7 +3046,7 @@ D3D12SerializeVersionedRootSignature_Detour (
#endif

D3D12_ROOT_SIGNATURE_DESC
RootSigCopy;
RootSigCopy = { };
RootSigCopy.NumParameters = pRootSignature->Desc_1_0.NumParameters;
RootSigCopy.pParameters = pRootSignature->Desc_1_0.pParameters;
RootSigCopy.NumStaticSamplers = pRootSignature->Desc_1_0.NumStaticSamplers;
Expand Down Expand Up @@ -3203,7 +3203,7 @@ D3D12SerializeRootSignature_Detour ( const D3D12_ROOT_SIGNATURE_DESC* pRootSigna
#endif

D3D12_ROOT_SIGNATURE_DESC
RootSigCopy;
RootSigCopy = { };
RootSigCopy.NumParameters = pRootSignature->NumParameters;
RootSigCopy.pParameters = pRootSignature->pParameters;
RootSigCopy.NumStaticSamplers = pRootSignature->NumStaticSamplers;
Expand Down
16 changes: 7 additions & 9 deletions src/render/gl/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,8 +1636,8 @@ SK_Overlay_DrawGL (void)

SK_GL_GhettoStateBlock_Capture ();

static RECT rect = { -1, -1, -1, -1 };
RECT rect_now = { 0, 0, 0, 0 };
static thread_local RECT rect = { -1, -1, -1, -1 };
RECT rect_now = { 0, 0, 0, 0 };

GetClientRect (SK_TLS_Bottom ()->render->gl->current_hwnd, &rect_now);

Expand Down Expand Up @@ -1730,7 +1730,7 @@ struct SK_IndirectX_InteropCtx
SK_ComPtr <ID3D11Device> pDevice;
SK_ComPtr <ID3D11DeviceContext> pDevCtx;
HANDLE hInteropDevice = nullptr;
D3D_FEATURE_LEVEL featureLevel;
D3D_FEATURE_LEVEL featureLevel = {};

struct staging_s {
SK_ComPtr <ID3D11SamplerState> colorSampler;
Expand Down Expand Up @@ -1899,13 +1899,11 @@ SK_IndirectX_PresentManager::Start (SK_IndirectX_InteropCtx *pCtx)
: 0x0 ) );


SK_ReleaseAssert (bSuccess);
InterlockedIncrement64 (&pCtx->present_man.frames_complete);


if (bSuccess)
SetEvent (pCtx->present_man.hAckPresent);
else
SetEvent (pCtx->present_man.hAckPresent);
SetEvent (pCtx->present_man.hAckPresent);

InterlockedCompareExchange (&lLock, 0, 1);
}
Expand Down Expand Up @@ -2197,7 +2195,7 @@ SK_GL_SwapBuffers (HDC hDC, LPVOID pfnSwapFunc)
compatible_dc = true;
}

if (! compatible_dc)
if (! compatible_dc) //TODO: V1036 https://pvs-studio.com/en/docs/warnings/v1036/ Potentially unsafe double-checked locking.
{
// Ensure the resources we created on the primary context are meaningful
// on this one.
Expand Down Expand Up @@ -4387,7 +4385,7 @@ glNamedFramebufferTexture_SK ( GLuint framebuffer,
}
}

else if (textureFmt == GL_RGB10_A2)
else // (textureFmt == GL_RGB10_A2)
{
InterlockedIncrement (&SK_HDR_RenderTargets_10bpc->CandidatesSeen);

Expand Down
16 changes: 8 additions & 8 deletions src/render/screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2664,14 +2664,14 @@ SK_Screenshot_SaveUHDR (const DirectX::Image& image, const DirectX::Image& sdr_i
if (! isUHDREncoderAvailable ())
return;

uhdr_raw_image raw_hdr;

raw_hdr.fmt = UHDR_IMG_FMT_32bppRGBA1010102;
raw_hdr.cg = UHDR_CG_BT_2100;
raw_hdr.ct = UHDR_CT_PQ;
raw_hdr.range = UHDR_CR_FULL_RANGE;
raw_hdr.w = static_cast <unsigned int> (image.width);
raw_hdr.h = static_cast <unsigned int> (image.height);
uhdr_raw_image
raw_hdr = {};
raw_hdr.fmt = UHDR_IMG_FMT_32bppRGBA1010102;
raw_hdr.cg = UHDR_CG_BT_2100;
raw_hdr.ct = UHDR_CT_PQ;
raw_hdr.range = UHDR_CR_FULL_RANGE;
raw_hdr.w = static_cast <unsigned int> (image.width);
raw_hdr.h = static_cast <unsigned int> (image.height);

using namespace DirectX;

Expand Down
Loading

0 comments on commit 34f04c0

Please sign in to comment.