diff --git a/Common/Misc.cpp b/Common/Misc.cpp index 73307cdbb8..460b64c3ee 100644 --- a/Common/Misc.cpp +++ b/Common/Misc.cpp @@ -50,7 +50,7 @@ const char *GetStringErrorMsg(int errCode) { err_strw, buff_size, NULL); static __declspec(thread) char err_str[buff_size] = {}; - snprintf(err_str, buff_size, ConvertWStringToUTF8(err_strw).c_str()); + snprintf(err_str, buff_size, "%s", ConvertWStringToUTF8(err_strw).c_str()); #else static __thread char err_str[buff_size] = {}; diff --git a/Common/Vulkan/SPIRVDisasm.cpp b/Common/Vulkan/SPIRVDisasm.cpp index 4c6e78de41..4d7a24c2cb 100644 --- a/Common/Vulkan/SPIRVDisasm.cpp +++ b/Common/Vulkan/SPIRVDisasm.cpp @@ -468,7 +468,8 @@ bool DisassembleSPIRV(std::vector spirv, std::string *output) { uint32_t d = spirv[i]; int wordCount = d >> 16; int opcode = d & 0xFFFF; - const OpInfo &op = opInfo[opcode]; + // Force to a valid index in the array. + const OpInfo &op = opInfo[opcode >= (int)ARRAY_SIZE(opInfo) ? 0 : opcode]; int target = (i < (int)spirv.size() - 1) ? spirv[(i + 1)] : 0; // Not always, but used often enough that we get it here. int source, source2, resType; std::string name; diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 29a0168df6..c9588334cb 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1648,18 +1648,21 @@ u32 __KernelDeleteThread(SceUID threadID, int exitStatus, const char *reason) } t->Cleanup(); - } - // Before triggering, set v0. It'll be restored if one is called. - RETURN(error); - t->nt.status = THREADSTATUS_DEAD; + // Before triggering, set v0. It'll be restored if one is called. + RETURN(error); + t->nt.status = THREADSTATUS_DEAD; - if (__KernelThreadTriggerEvent((t->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0, threadID, THREADEVENT_DELETE)) { - // Don't delete it yet. We'll delete later. - pendingDeleteThreads.push_back(threadID); - return 0; + if (__KernelThreadTriggerEvent((t->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0, threadID, THREADEVENT_DELETE)) { + // Don't delete it yet. We'll delete later. + pendingDeleteThreads.push_back(threadID); + return 0; + } else { + return kernelObjects.Destroy(threadID); + } } else { - return kernelObjects.Destroy(threadID); + RETURN(error); + return error; } } diff --git a/Core/HLE/sceKernelTime.cpp b/Core/HLE/sceKernelTime.cpp index b74772df3b..c656a3f8ce 100644 --- a/Core/HLE/sceKernelTime.cpp +++ b/Core/HLE/sceKernelTime.cpp @@ -176,7 +176,7 @@ u32 sceKernelLibcGettimeofday(u32 timeAddr, u32 tzAddr) std::string KernelTimeNowFormatted() { time_t emulatedTime = (time_t)start_time + (u32)(CoreTiming::GetGlobalTimeUs() / 1000000ULL); tm* timePtr = localtime(&emulatedTime); - bool DST = timePtr->tm_isdst; + bool DST = timePtr->tm_isdst != 0; u8 seconds = timePtr->tm_sec; u8 minutes = timePtr->tm_min; u8 hours = timePtr->tm_hour; @@ -187,4 +187,4 @@ std::string KernelTimeNowFormatted() { u16 years = timePtr->tm_year + 1900; std::string timestamp = StringFromFormat("%04d-%02d-%02d_%02d-%02d-%02d", years, months, days, hours, minutes, seconds); return timestamp; -} \ No newline at end of file +} diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index b46f429f90..540aad3adf 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -171,7 +171,7 @@ void TextureReplacer::ParseHashRange(const std::string &key, const std::string & return; } - const u64 rangeKey = ((u64)addr << 32) | (fromW << 16) | fromH; + const u64 rangeKey = ((u64)addr << 32) | ((u64)fromW << 16) | fromH; hashranges_[rangeKey] = WidthHeightPair(toW, toH); } @@ -511,7 +511,7 @@ std::string TextureReplacer::HashName(u64 cachekey, u32 hash, int level) { } bool TextureReplacer::LookupHashRange(u32 addr, int &w, int &h) { - const u64 rangeKey = ((u64)addr << 32) | (w << 16) | h; + const u64 rangeKey = ((u64)addr << 32) | ((u64)w << 16) | h; auto range = hashranges_.find(rangeKey); if (range != hashranges_.end()) { const WidthHeightPair &wh = range->second; diff --git a/GPU/Common/ShaderTranslation.cpp b/GPU/Common/ShaderTranslation.cpp index 1a50efbaba..0ca126281b 100644 --- a/GPU/Common/ShaderTranslation.cpp +++ b/GPU/Common/ShaderTranslation.cpp @@ -156,7 +156,6 @@ bool ConvertToVulkanGLSL(std::string *dest, TranslatedShaderMetadata *destMetada std::string line; std::stringstream instream(src); while (std::getline(instream, line)) { - char buffer[256]; int vecSize, num; if (line.find("uniform bool") != std::string::npos) { continue; diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index b38faffb47..29af15c020 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -1,4 +1,19 @@ -#pragma once +// Copyright (c) 2014- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "GPU/Common/StencilCommon.h" diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 3e37f99075..23ae269e0d 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -2364,7 +2364,7 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) { #ifndef MOBILE_DEVICE CBreakPoints::ExecMemCheck(srcBasePtr + (srcY * srcStride + srcX) * bpp, false, height * srcStride * bpp, currentMIPS->pc); - CBreakPoints::ExecMemCheck(dstBasePtr + (srcY * dstStride + srcX) * bpp, true, height * dstStride * bpp, currentMIPS->pc); + CBreakPoints::ExecMemCheck(dstBasePtr + (dstY * dstStride + dstX) * bpp, true, height * dstStride * bpp, currentMIPS->pc); #endif // TODO: Correct timing appears to be 1.9, but erring a bit low since some of our other timing is inaccurate. diff --git a/ext/native/base/colorutil.cpp b/ext/native/base/colorutil.cpp index 927a871179..9accdda53c 100644 --- a/ext/native/base/colorutil.cpp +++ b/ext/native/base/colorutil.cpp @@ -22,10 +22,10 @@ uint32_t colorAlpha(uint32_t rgb, float alpha) { uint32_t alphaMul(uint32_t color, float alphaMul) { uint32_t rgb = color & 0xFFFFFF; - uint32_t alpha = color >> 24; + int32_t alpha = color >> 24; alpha *= alphaMul; - if (alpha < 0) alpha = 0.0f; - if (alpha > 255) alpha = 255.0f; + if (alpha < 0) alpha = 0; + if (alpha > 255) alpha = 255; return (alpha << 24) | (rgb & 0xFFFFFF); } diff --git a/ext/native/gfx_es2/draw_text_android.cpp b/ext/native/gfx_es2/draw_text_android.cpp index 922e578a6e..19dc593255 100644 --- a/ext/native/gfx_es2/draw_text_android.cpp +++ b/ext/native/gfx_es2/draw_text_android.cpp @@ -174,7 +174,7 @@ void TextDrawerAndroid::DrawString(DrawBuffer &target, const char *str, float x, entry->lastUsedFrame = frameCount_; draw_->BindTexture(0, entry->texture); } else { - double size; + double size = 0.0; auto iter = fontMap_.find(fontHash_); if (iter != fontMap_.end()) { size = iter->second.size; diff --git a/ppsspp_config.h b/ppsspp_config.h index e1ff1869b2..9d585b70be 100644 --- a/ppsspp_config.h +++ b/ppsspp_config.h @@ -82,7 +82,7 @@ #define PPSSPP_PLATFORM_WINDOWS 1 // UWP trickery #if defined(WINAPI_FAMILY) && defined(WINAPI_FAMILY_PARTITION) - #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP #define PPSSPP_PLATFORM_UWP 1 #ifdef _M_ARM #define PPSSPP_ARCH_ARM_HARDFP 1