diff --git a/Common/Data/Collections/FastVec.h b/Common/Data/Collections/FastVec.h index 17f00441ba..6993de36d7 100644 --- a/Common/Data/Collections/FastVec.h +++ b/Common/Data/Collections/FastVec.h @@ -125,11 +125,12 @@ public: size_ += count; } + // Adds this number of new T to the end, and returns the pointer to them. T *extend_uninitialized(size_t count) { - size_t sz = size_; + const size_t prevSize = size_; if (size_ + count <= capacity_) { size_ += count; - return &data_[sz]; + return data_ + prevSize; } else { size_t newCapacity = size_ + count * 2; // Leave some extra room when growing in all cases if (newCapacity < capacity_ * 2) { @@ -138,7 +139,7 @@ public: } IncreaseCapacityTo(newCapacity); size_ += count; - return &data_[sz]; + return data_ + prevSize; } } diff --git a/Common/Data/Format/ZIMLoad.cpp b/Common/Data/Format/ZIMLoad.cpp index d61559e9eb..daace4992d 100644 --- a/Common/Data/Format/ZIMLoad.cpp +++ b/Common/Data/Format/ZIMLoad.cpp @@ -59,7 +59,7 @@ int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int memcpy(flags, zim + 12, 4); int num_levels = 1; - int image_data_size[ZIM_MAX_MIP_LEVELS]; + int image_data_size[ZIM_MAX_MIP_LEVELS]{}; if (*flags & ZIM_HAS_MIPS) { num_levels = log2i(*width < *height ? *width : *height) + 1; } diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 9ecc2904a6..4e54c936b9 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -1156,8 +1156,7 @@ const Path GetCurDirectory() { return Path(curDir); #else char temp[4096]{}; - getcwd(temp, 4096); - return Path(temp); + return Path(getcwd(temp, 4096)); #endif } diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index ce5ffad52b..243664b295 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -451,7 +451,7 @@ public: PendingDescSet &descSet = data.descSets_.push_uninitialized(); descSet.offset = (uint32_t)offset; descSet.count = count; - // descSet.set = VK_NULL_HANDLE; // to be filled in + descSet.set = VK_NULL_HANDLE; // to be filled in *descSetIndex = setIndex; return retval; } diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 66e5581346..81ccd841ea 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -23,6 +23,7 @@ #include "Common/File/VFS/VFS.h" #include "Common/StringUtils.h" #include "Common/System/OSD.h" +#include "Common/System/System.h" #include "Core/Compatibility.h" #include "Core/Config.h" #include "Core/System.h" @@ -59,20 +60,23 @@ void Compatibility::Load(const std::string &gameID) { } } - { - IniFile compat; - // This loads from assets. - if (compat.LoadFromVFS(g_VFS, "compatvr.ini")) { - CheckVRSettings(compat, gameID); + const int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE); + if ((deviceType == DEVICE_TYPE_VR) || g_Config.bForceVR) { + { + IniFile compat; + // This loads from assets. + if (compat.LoadFromVFS(g_VFS, "compatvr.ini")) { + CheckVRSettings(compat, gameID); + } } - } - { - IniFile compat2; - // This one is user-editable. Need to load it after the system one. - Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compatvr.ini"; - if (compat2.Load(path)) { - CheckVRSettings(compat2, gameID); + { + IniFile compat2; + // This one is user-editable. Need to load it after the system one. + Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compatvr.ini"; + if (compat2.Load(path)) { + CheckVRSettings(compat2, gameID); + } } } } diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index f487624e02..366a8b7cc9 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -283,7 +283,7 @@ float ControlMapper::MapAxisValue(float value, int vkId, const InputMapping &map // If a signed axis is mapped to an unsigned mapping, // convert it. This happens when mapping DirectInput triggers to analog speed, // for example. - int direction; + int direction = 0; if (IsSignedAxis(mapping.Axis(&direction))) { // The value has been split up into two curInput values, so we need to go fetch the other // and put them back together again. Kind of awkward, but at least makes the regular case simple... diff --git a/Core/Dialog/PSPGamedataInstallDialog.h b/Core/Dialog/PSPGamedataInstallDialog.h index 859d9a3d72..eb11708526 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.h +++ b/Core/Dialog/PSPGamedataInstallDialog.h @@ -61,7 +61,7 @@ private: void WriteSfoFile(); SceUtilityGamedataInstallParam request{}; - PSPPointer param; + PSPPointer param{}; std::vector inFileNames; int numFiles = 0; int readFiles = 0; diff --git a/Core/Dialog/PSPNetconfDialog.h b/Core/Dialog/PSPNetconfDialog.h index 9c0589d2d9..54bc5a1abf 100644 --- a/Core/Dialog/PSPNetconfDialog.h +++ b/Core/Dialog/PSPNetconfDialog.h @@ -53,7 +53,7 @@ private: void DrawBanner(); void DrawIndicator(); - SceUtilityNetconfParam request = {}; + SceUtilityNetconfParam request{}; u32 requestAddr = 0; int connResult = -1; diff --git a/Core/Dialog/PSPScreenshotDialog.h b/Core/Dialog/PSPScreenshotDialog.h index f6195faec2..c5eb2c0c06 100644 --- a/Core/Dialog/PSPScreenshotDialog.h +++ b/Core/Dialog/PSPScreenshotDialog.h @@ -39,6 +39,6 @@ protected: return true; } - int mode; - PSPPointer params_; + int mode = 0; + PSPPointer params_{}; }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 38d4b5759b..a77d836bb7 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1350,7 +1350,7 @@ skip: for (auto iter = range.first; iter != range.second; ++iter) { AnalyzedFunction &f = *iter->second; if (f.hash == mf->hash && f.size == mf->size) { - strncpy(f.name, mf->name, sizeof(mf->name) - 1); + truncate_cpy(f.name, mf->name); std::string existingLabel = g_symbolMap->GetLabelString(f.start); char defaultLabel[256]; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 5052447357..277437d421 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1196,7 +1196,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int float u0 = 0.0f, u1 = 1.0f; float v0 = 0.0f, v1 = 1.0f; - DrawTextureFlags flags; + DrawTextureFlags flags = DrawTextureFlags::DRAWTEX_DEFAULT; if (useBufferedRendering_ && vfb) { _dbg_assert_(vfb->fbo); if (vfb->fbo) { @@ -2102,10 +2102,10 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, // For now fill in these old variables from the candidates to reduce the initial diff. VirtualFramebuffer *dstBuffer = nullptr; VirtualFramebuffer *srcBuffer = nullptr; - int srcY; - int srcH; - int dstY; - int dstH; + int srcY = 0; + int srcH = 0; + int dstY = 0; + int dstH = 0; const CopyCandidate *bestSrc = GetBestCopyCandidate(srcCandidates, src, channel); if (bestSrc) { diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 5d96abd37d..883a51a77b 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -211,13 +211,14 @@ enum BindFramebufferColorFlags { }; enum DrawTextureFlags { + DRAWTEX_DEFAULT = 0, DRAWTEX_NEAREST = 0, DRAWTEX_LINEAR = 1, DRAWTEX_TO_BACKBUFFER = 8, DRAWTEX_DEPTH = 16, }; -inline DrawTextureFlags operator | (const DrawTextureFlags &lhs, const DrawTextureFlags &rhs) { +inline DrawTextureFlags operator | (DrawTextureFlags lhs, DrawTextureFlags rhs) { return DrawTextureFlags((u32)lhs | (u32)rhs); } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index e30ecffc61..e02aeced0b 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -389,8 +389,11 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin dirtyUniforms = 0; // Analyze scene - bool is2D, flatScreen; - if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + bool is2D = false, flatScreen = false; + + const bool useVR = gstate_c.Use(GPU_USE_VIRTUAL_REALITY); + + if (useVR) { is2D = Is2DVRObject(gstate.projMatrix, gstate.isModeThrough()); flatScreen = IsFlatVRScene(); } @@ -410,7 +413,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin } // Set HUD mode - if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + if (useVR) { if (GuessVRDrawingHUD(is2D, flatScreen)) { float aspect = 480.0f / 272.0f * (IsImmersiveVRMode() ? 0.5f : 1.0f); render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDisplayScale * aspect); @@ -423,7 +426,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin // Update any dirty uniforms before we draw if (dirty & DIRTY_PROJMATRIX) { - if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + if (useVR) { Matrix4x4 vrProjection; if (flatScreen || is2D) { memcpy(&vrProjection, gstate.projMatrix, 16 * sizeof(float)); @@ -482,7 +485,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin } if (dirty & DIRTY_FOGCOLOR) { SetColorUniform3(render_, &u_fogcolor, gstate.fogcolor); - if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + if (useVR) { SetVRCompat(VR_COMPAT_FOG_COLOR, gstate.fogcolor); } } @@ -567,7 +570,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin SetMatrix4x3(render_, &u_world, gstate.worldMatrix); } if (dirty & DIRTY_VIEWMATRIX) { - if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + if (useVR) { float leftEyeView[16]; float rightEyeView[16]; ConvertMatrix4x3To4x4Transposed(leftEyeView, gstate.viewMatrix); diff --git a/ext/libkirk/AES.h b/ext/libkirk/AES.h index b6474ec4c0..ee61f46490 100644 --- a/ext/libkirk/AES.h +++ b/ext/libkirk/AES.h @@ -44,9 +44,8 @@ void AES_cbc_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size); void AES_cbc_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size); void AES_CMAC(AES_ctx *ctx, const unsigned char *input, int length, unsigned char *mac); -int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int); -int rijndaelKeySetupDec(unsigned int [], const unsigned char [], int); -void rijndaelEncrypt(const unsigned int [], int, const unsigned char [], - unsigned char []); +int rijndaelKeySetupEnc(u32 [], const u8 [], int); +int rijndaelKeySetupDec(u32 [], const u8 [], int); +void rijndaelEncrypt(const u32 [], int, const u8 pt[16], u8 ct[16]); #endif /* __RIJNDAEL_H */