mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
HLE: Small kernel cleanups
Initialize the wokeThreads locals that were passed by reference uninitialized in the event flag, VPL and semaphore timeout handlers. Harmless today since the callee only ever assigns to them, but every other use in the same files starts at false. Do the semaphore overflow check in 64-bit, so a large signal value can't wrap past it into currentCount.
This commit is contained in:
1 parent
00e2e89914
commit
c4160b4eed
3 files changed
+5
-4
No files matched your search
@@ -285,7 +285,7 @@ void __KernelEventFlagTimeout(u64 userdata, int cycleslate) {
|
||||
for (size_t i = 0; i < e->waitingThreads.size(); i++) {
|
||||
EventFlagTh *t = &e->waitingThreads[i];
|
||||
if (t->threadID == threadID) {
|
||||
bool wokeThreads;
|
||||
bool wokeThreads = false;
|
||||
|
||||
// This thread isn't waiting anymore, but we'll remove it from waitingThreads later.
|
||||
// The reason is, if it times out, but what it was waiting on is DELETED prior to it
|
||||
|
||||
@@ -1435,7 +1435,7 @@ void __KernelVplTimeout(u64 userdata, int cyclesLate) {
|
||||
// If in FIFO mode, that may have cleared another thread to wake up.
|
||||
VPL *vpl = kernelObjects.Get<VPL>(uid, error);
|
||||
if (vpl && (vpl->nv.attr & PSP_VPL_ATTR_MASK_ORDER) == PSP_VPL_ATTR_FIFO) {
|
||||
bool wokeThreads;
|
||||
bool wokeThreads = false;
|
||||
std::vector<VplWaitingThread>::iterator iter = vpl->waitingThreads.begin();
|
||||
// Unlock every waiting thread until the first that must still wait.
|
||||
while (iter != vpl->waitingThreads.end() && __KernelUnlockVplForThread(vpl, *iter, error, 0, wokeThreads)) {
|
||||
|
||||
@@ -242,7 +242,8 @@ int sceKernelSignalSema(SceUID id, int signal) {
|
||||
return hleLogError(Log::sceKernel, error, "bad sema id");
|
||||
}
|
||||
} else {
|
||||
if (s->ns.currentCount + signal - (int) s->waitingThreads.size() > s->ns.maxCount) {
|
||||
// Done in 64-bit so a huge signal value can't overflow its way past the check.
|
||||
if ((s64)s->ns.currentCount + signal - (s64)s->waitingThreads.size() > s->ns.maxCount) {
|
||||
return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_SEMA_OVF, "overflow at %d", s->ns.currentCount);
|
||||
}
|
||||
|
||||
@@ -279,7 +280,7 @@ void __KernelSemaTimeout(u64 userdata, int cycleslate) {
|
||||
// If in FIFO mode, that may have cleared another thread to wake up.
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(uid, error);
|
||||
if (s && (s->ns.attr & PSP_SEMA_ATTR_PRIORITY) == PSP_SEMA_ATTR_FIFO) {
|
||||
bool wokeThreads;
|
||||
bool wokeThreads = false;
|
||||
std::vector<SceUID>::iterator iter = s->waitingThreads.begin();
|
||||
// Unlock every waiting thread until the first that must still wait.
|
||||
while (iter != s->waitingThreads.end() && __KernelUnlockSemaForThread(s, *iter, error, 0, wokeThreads)) {
|
||||
|
||||
Reference in new issue
Block a user