mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-06 13:08:52 +02:00
misc: chore: Merge duplicated 'if' branches
This commit is contained in:
@@ -276,29 +276,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
||||
WakeClientThread(request, clientResult);
|
||||
}
|
||||
|
||||
if (clientHeader.ReceiveListType < 2 &&
|
||||
clientHeader.ReceiveListOffset > clientMsg.Size)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
else if (clientHeader.ReceiveListType == 2 &&
|
||||
clientHeader.ReceiveListOffset + 8 > clientMsg.Size)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
else if (clientHeader.ReceiveListType > 2 &&
|
||||
clientHeader.ReceiveListType * 8 - 0x10 + clientHeader.ReceiveListOffset > clientMsg.Size)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
if (clientHeader.ReceiveListOffsetInWords < clientHeader.MessageSizeInWords)
|
||||
if (clientHeader.ReceiveListType < 2 && clientHeader.ReceiveListOffset > clientMsg.Size ||
|
||||
clientHeader.ReceiveListType == 2 && clientHeader.ReceiveListOffset + 8 > clientMsg.Size ||
|
||||
clientHeader.ReceiveListType > 2 && clientHeader.ReceiveListType * 8 - 0x10 + clientHeader.ReceiveListOffset > clientMsg.Size ||
|
||||
clientHeader.ReceiveListOffsetInWords < clientHeader.MessageSizeInWords)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
@@ -629,29 +610,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
||||
FinishRequest(request, clientResult);
|
||||
}
|
||||
|
||||
if (clientHeader.ReceiveListType < 2 &&
|
||||
clientHeader.ReceiveListOffset > clientMsg.Size)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
else if (clientHeader.ReceiveListType == 2 &&
|
||||
clientHeader.ReceiveListOffset + 8 > clientMsg.Size)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
else if (clientHeader.ReceiveListType > 2 &&
|
||||
clientHeader.ReceiveListType * 8 - 0x10 + clientHeader.ReceiveListOffset > clientMsg.Size)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
if (clientHeader.ReceiveListOffsetInWords < clientHeader.MessageSizeInWords)
|
||||
if (clientHeader.ReceiveListType < 2 && clientHeader.ReceiveListOffset > clientMsg.Size ||
|
||||
clientHeader.ReceiveListType == 2 && clientHeader.ReceiveListOffset + 8 > clientMsg.Size ||
|
||||
clientHeader.ReceiveListType > 2 && clientHeader.ReceiveListType * 8 - 0x10 + clientHeader.ReceiveListOffset > clientMsg.Size ||
|
||||
clientHeader.ReceiveListOffsetInWords < clientHeader.MessageSizeInWords)
|
||||
{
|
||||
CleanUpForError();
|
||||
|
||||
|
||||
@@ -442,17 +442,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
ulong addrSpacePagesCount = (AddressSpaceEnd - AddressSpaceStart) / PageSize;
|
||||
|
||||
if (AddressSpaceStart > address)
|
||||
{
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
if (addrSpacePagesCount < pagesCount)
|
||||
{
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
if (endAddr - 1 > AddressSpaceEnd - 1)
|
||||
if (AddressSpaceStart > address || addrSpacePagesCount < pagesCount || endAddr - 1 > AddressSpaceEnd - 1)
|
||||
{
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
@@ -309,17 +309,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
if (KernelContext.EnableVersionChecks)
|
||||
{
|
||||
if (requiredKernelVersionMajor > KernelVersionMajor)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
if (requiredKernelVersionMajor != KernelVersionMajor && requiredKernelVersionMajor < 3)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
if (requiredKernelVersionMinor > KernelVersionMinor)
|
||||
if (requiredKernelVersionMajor > KernelVersionMajor ||
|
||||
requiredKernelVersionMajor != KernelVersionMajor && requiredKernelVersionMajor < 3 ||
|
||||
requiredKernelVersionMinor > KernelVersionMinor)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
@@ -535,12 +535,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
ulong copySize = (ulong)((long)handlesCount * 4);
|
||||
|
||||
if (!currentProcess.MemoryManager.InsideAddrSpace(handlesPtr, copySize))
|
||||
{
|
||||
return KernelResult.UserCopyFailed;
|
||||
}
|
||||
|
||||
if (handlesPtr + copySize < handlesPtr)
|
||||
if (!currentProcess.MemoryManager.InsideAddrSpace(handlesPtr, copySize) ||
|
||||
handlesPtr + copySize < handlesPtr)
|
||||
{
|
||||
return KernelResult.UserCopyFailed;
|
||||
}
|
||||
@@ -647,12 +643,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
ulong copySize = (ulong)((long)handlesCount * 4);
|
||||
|
||||
if (!currentProcess.MemoryManager.InsideAddrSpace(handlesPtr, copySize))
|
||||
{
|
||||
return KernelResult.UserCopyFailed;
|
||||
}
|
||||
|
||||
if (handlesPtr + copySize < handlesPtr)
|
||||
if (!currentProcess.MemoryManager.InsideAddrSpace(handlesPtr, copySize) ||
|
||||
handlesPtr + copySize < handlesPtr)
|
||||
{
|
||||
return KernelResult.UserCopyFailed;
|
||||
}
|
||||
@@ -2268,12 +2260,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
ulong copySize = (ulong)maxCount * 8;
|
||||
|
||||
if (address + copySize <= address)
|
||||
{
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
if (currentProcess.MemoryManager.OutsideAddrSpace(address, copySize))
|
||||
if (address + copySize <= address ||
|
||||
currentProcess.MemoryManager.OutsideAddrSpace(address, copySize))
|
||||
{
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
@@ -2742,12 +2730,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
KThread thread = process.HandleTable.GetObject<KThread>(handle);
|
||||
|
||||
if (thread == null)
|
||||
{
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
|
||||
if (thread.Owner != process)
|
||||
if (thread == null || thread.Owner != process)
|
||||
{
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
@@ -2768,12 +2751,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
KThread thread = currentProcess.HandleTable.GetObject<KThread>(handle);
|
||||
|
||||
if (thread == null)
|
||||
{
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
|
||||
if (thread.Owner != currentProcess)
|
||||
if (thread == null || thread.Owner != currentProcess)
|
||||
{
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
@@ -2820,12 +2798,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
long handlesSize = handlesCount * 4;
|
||||
|
||||
if (handlesPtr + (ulong)handlesSize <= handlesPtr)
|
||||
{
|
||||
return KernelResult.UserCopyFailed;
|
||||
}
|
||||
|
||||
if (handlesPtr + (ulong)handlesSize - 1 > currentProcess.MemoryManager.AddressSpaceEnd - 1)
|
||||
if (handlesPtr + (ulong)handlesSize <= handlesPtr ||
|
||||
handlesPtr + (ulong)handlesSize - 1 > currentProcess.MemoryManager.AddressSpaceEnd - 1)
|
||||
{
|
||||
return KernelResult.UserCopyFailed;
|
||||
}
|
||||
|
||||
@@ -214,12 +214,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
DeviceType deviceType = (DeviceType)context.RequestData.ReadUInt32();
|
||||
MountTarget mountTarget = (MountTarget)context.RequestData.ReadUInt32();
|
||||
|
||||
if (deviceType != 0)
|
||||
{
|
||||
return ResultCode.WrongArgument;
|
||||
}
|
||||
|
||||
if (((uint)mountTarget & 3) == 0)
|
||||
if (deviceType != 0 || ((uint)mountTarget & 3) == 0)
|
||||
{
|
||||
return ResultCode.WrongArgument;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
{
|
||||
VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId);
|
||||
|
||||
return new CommonInfo()
|
||||
return new CommonInfo
|
||||
{
|
||||
LastWriteYear = (ushort)amiiboFile.LastWriteDate.Year,
|
||||
LastWriteMonth = (byte)amiiboFile.LastWriteDate.Month,
|
||||
@@ -115,19 +115,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
public static bool OpenApplicationArea(string amiiboId, uint applicationAreaId)
|
||||
{
|
||||
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
|
||||
if (ApplicationBytes.Length > 0)
|
||||
if (ApplicationBytes.Length > 0 ||
|
||||
virtualAmiiboFile.ApplicationAreas.Any(item => item.ApplicationAreaId == applicationAreaId))
|
||||
{
|
||||
OpenedApplicationAreaId = applicationAreaId;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (virtualAmiiboFile.ApplicationAreas.Any(item => item.ApplicationAreaId == applicationAreaId))
|
||||
{
|
||||
OpenedApplicationAreaId = applicationAreaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -161,7 +155,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
return false;
|
||||
}
|
||||
|
||||
virtualAmiiboFile.ApplicationAreas.Add(new VirtualAmiiboApplicationArea()
|
||||
virtualAmiiboFile.ApplicationAreas.Add(new VirtualAmiiboApplicationArea
|
||||
{
|
||||
ApplicationAreaId = applicationAreaId,
|
||||
ApplicationArea = applicationAreaData,
|
||||
@@ -187,7 +181,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
{
|
||||
if (virtualAmiiboFile.ApplicationAreas[i].ApplicationAreaId == OpenedApplicationAreaId)
|
||||
{
|
||||
virtualAmiiboFile.ApplicationAreas[i] = new VirtualAmiiboApplicationArea()
|
||||
virtualAmiiboFile.ApplicationAreas[i] = new VirtualAmiiboApplicationArea
|
||||
{
|
||||
ApplicationAreaId = OpenedApplicationAreaId,
|
||||
ApplicationArea = applicationAreaData,
|
||||
@@ -215,7 +209,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
}
|
||||
else
|
||||
{
|
||||
virtualAmiiboFile = new VirtualAmiiboFile()
|
||||
virtualAmiiboFile = new VirtualAmiiboFile
|
||||
{
|
||||
FileVersion = 0,
|
||||
TagUuid = [],
|
||||
|
||||
@@ -117,11 +117,8 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
||||
{
|
||||
return ResultCode.TooManyNro;
|
||||
}
|
||||
else if (nroSize == 0 || nroAddress + nroSize <= nroAddress || (nroSize & 0xFFF) != 0)
|
||||
{
|
||||
return ResultCode.InvalidSize;
|
||||
}
|
||||
else if (bssSize != 0 && bssAddress + bssSize <= bssAddress)
|
||||
else if (nroSize == 0 || nroAddress + nroSize <= nroAddress || (nroSize & 0xFFF) != 0 ||
|
||||
bssSize != 0 && bssAddress + bssSize <= bssAddress)
|
||||
{
|
||||
return ResultCode.InvalidSize;
|
||||
}
|
||||
|
||||
@@ -366,12 +366,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
|
||||
int maxBufferCount = Core.GetMaxBufferCountLocked(input.Async != 0);
|
||||
|
||||
if (input.Async != 0 && Core.OverrideMaxBufferCount != 0 && Core.OverrideMaxBufferCount < maxBufferCount)
|
||||
{
|
||||
return Status.BadValue;
|
||||
}
|
||||
|
||||
if (slot < 0 || slot >= Core.Slots.Length || !Core.IsOwnedByProducerLocked(slot))
|
||||
if (input.Async != 0 && Core.OverrideMaxBufferCount != 0 && Core.OverrideMaxBufferCount < maxBufferCount ||
|
||||
slot < 0 || slot >= Core.Slots.Length || !Core.IsOwnedByProducerLocked(slot))
|
||||
{
|
||||
return Status.BadValue;
|
||||
}
|
||||
|
||||
@@ -236,14 +236,8 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
|
||||
var tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (tokens.Length < 2)
|
||||
{
|
||||
ParseWarn();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!int.TryParse(tokens[0], System.Globalization.NumberStyles.HexNumber, null, out int offset))
|
||||
if (tokens.Length < 2 ||
|
||||
!int.TryParse(tokens[0], System.Globalization.NumberStyles.HexNumber, null, out int offset))
|
||||
{
|
||||
ParseWarn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user