diff --git a/src/ARMeilleure/Translation/PTC/Ptc.cs b/src/ARMeilleure/Translation/PTC/Ptc.cs index 91c065aed..1c176cad3 100644 --- a/src/ARMeilleure/Translation/PTC/Ptc.cs +++ b/src/ARMeilleure/Translation/PTC/Ptc.cs @@ -244,56 +244,14 @@ namespace ARMeilleure.Translation.PTC { OuterHeader outerHeader = DeserializeStructure(compressedStream); - if (!outerHeader.IsHeaderValid()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.Magic != _outerHeaderMagic) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.CacheFileVersion != InternalVersion) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.Endianness != GetEndianness()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.FeatureInfo != GetFeatureInfo()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.MemoryManagerMode != GetMemoryManagerMode()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.OSPlatform != GetOSPlatform()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.Architecture != (uint)RuntimeInformation.ProcessArchitecture) + if (!outerHeader.IsHeaderValid() || + outerHeader.Magic != _outerHeaderMagic || + outerHeader.CacheFileVersion != InternalVersion || + outerHeader.Endianness != GetEndianness() || + outerHeader.FeatureInfo != GetFeatureInfo() || + outerHeader.MemoryManagerMode != GetMemoryManagerMode() || + outerHeader.OSPlatform != GetOSPlatform() || + outerHeader.Architecture != (uint)RuntimeInformation.ProcessArchitecture) { InvalidateCompressedStream(compressedStream); @@ -324,14 +282,7 @@ namespace ARMeilleure.Translation.PTC InnerHeader innerHeader = DeserializeStructure(stream); - if (!innerHeader.IsHeaderValid()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (innerHeader.Magic != _innerHeaderMagic) + if (!innerHeader.IsHeaderValid() || innerHeader.Magic != _innerHeaderMagic) { InvalidateCompressedStream(compressedStream); diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs index 59165af86..0ed0f4e65 100644 --- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs +++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs @@ -189,28 +189,10 @@ namespace ARMeilleure.Translation.PTC { OuterHeader outerHeader = DeserializeStructure(compressedStream); - if (!outerHeader.IsHeaderValid()) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.Magic != _outerHeaderMagic) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.InfoFileVersion != InternalVersion && !_migrateInternalVersions.Contains(outerHeader.InfoFileVersion)) - { - InvalidateCompressedStream(compressedStream); - - return false; - } - - if (outerHeader.Endianness != Ptc.GetEndianness()) + if (!outerHeader.IsHeaderValid() || + outerHeader.Magic != _outerHeaderMagic || + outerHeader.InfoFileVersion != InternalVersion && !_migrateInternalVersions.Contains(outerHeader.InfoFileVersion) || + outerHeader.Endianness != Ptc.GetEndianness()) { InvalidateCompressedStream(compressedStream); diff --git a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs index f67d0c124..fe3ab74d7 100644 --- a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs +++ b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs @@ -262,12 +262,8 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool return UpdateResult.Success; } - if (inParameter.CpuAddress == 0 || (inParameter.CpuAddress % PageSize) != 0) - { - return UpdateResult.InvalidParameter; - } - - if (inParameter.Size == 0 || (inParameter.Size % PageSize) != 0) + if (inParameter.CpuAddress == 0 || (inParameter.CpuAddress % PageSize) != 0 || + inParameter.Size == 0 || (inParameter.Size % PageSize) != 0) { return UpdateResult.InvalidParameter; } diff --git a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs index 5dc9129ac..3065ec82c 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs @@ -409,12 +409,8 @@ namespace Ryujinx.Cpu.Jit for (int page = 0; page < pages - 1; page++) { - if (!ValidateAddress(va + PageSize)) - { - return contiguousSize; - } - - if (GetPhysicalAddressInternal(va) + PageSize != GetPhysicalAddressInternal(va + PageSize)) + if (!ValidateAddress(va + PageSize) || + GetPhysicalAddressInternal(va) + PageSize != GetPhysicalAddressInternal(va + PageSize)) { return contiguousSize; } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs index cf765ec89..304809df3 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs @@ -852,11 +852,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed bool hasDepth = dsFormat.Format.HasDepth(); bool hasStencil = dsFormat.Format.HasStencil(); - if (hasStencil && (!clearStencil || (clearAffectedByStencilMask && _state.State.StencilTestState.FrontMask != 0xff))) - { - fullClear = false; - } - else if (hasDepth && !clearDepth) + if (hasStencil && (!clearStencil || (clearAffectedByStencilMask && _state.State.StencilTestState.FrontMask != 0xff)) || + hasDepth && !clearDepth) { fullClear = false; } diff --git a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs index 8ef0a1b91..62a49fd8d 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -1187,12 +1187,8 @@ namespace Ryujinx.Graphics.Gpu.Image return matchQuality; } - if (!TextureCompatibility.LayoutMatches(Info, info)) - { - return TextureMatchQuality.NoMatch; - } - - if (!TextureCompatibility.SizeMatches(Info, info, forSampler)) + if (!TextureCompatibility.LayoutMatches(Info, info) + || !TextureCompatibility.SizeMatches(Info, info, forSampler)) { return TextureMatchQuality.NoMatch; } @@ -1277,17 +1273,9 @@ namespace Ryujinx.Graphics.Gpu.Image int offset = Range.FindOffset(range); - if (offset < 0 || !_sizeInfo.FindView(offset, out firstLayer, out firstLevel)) - { - return TextureViewCompatibility.LayoutIncompatible; - } - - if (!TextureCompatibility.ViewLayoutCompatible(Info, info, firstLevel)) - { - return TextureViewCompatibility.LayoutIncompatible; - } - - if (info.GetSlices() > 1 && LayerSize != layerSize) + if (offset < 0 || !_sizeInfo.FindView(offset, out firstLayer, out firstLevel) || + !TextureCompatibility.ViewLayoutCompatible(Info, info, firstLevel) || + info.GetSlices() > 1 && LayerSize != layerSize) { return TextureViewCompatibility.LayoutIncompatible; } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs index f1444afe2..260a112b2 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs @@ -243,11 +243,8 @@ namespace Ryujinx.Graphics.Gpu.Image } else if ((lhs.FormatInfo.Format == Format.D24UnormS8Uint || lhs.FormatInfo.Format == Format.S8UintD24Unorm || - lhs.FormatInfo.Format == Format.X8UintD24Unorm) && rhs.FormatInfo.Format == Format.B8G8R8A8Unorm) - { - return TextureMatchQuality.FormatAlias; - } - else if (lhs.FormatInfo.Format == Format.D32FloatS8Uint && rhs.FormatInfo.Format == Format.R32G32Float) + lhs.FormatInfo.Format == Format.X8UintD24Unorm) && rhs.FormatInfo.Format == Format.B8G8R8A8Unorm || + lhs.FormatInfo.Format == Format.D32FloatS8Uint && rhs.FormatInfo.Format == Format.R32G32Float) { return TextureMatchQuality.FormatAlias; } diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFmpegApi.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFmpegApi.cs index 15b620bf2..ca98eee1b 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFmpegApi.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFmpegApi.cs @@ -62,11 +62,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native NativeLibrary.SetDllImportResolver(typeof(FFmpegApi).Assembly, (name, assembly, path) => { - if (name == AvUtilLibraryName && TryLoadWhitelistedLibrary(AvUtilLibraryName, assembly, path, out nint handle)) - { - return handle; - } - else if (name == AvCodecLibraryName && TryLoadWhitelistedLibrary(AvCodecLibraryName, assembly, path, out handle)) + if (name == AvUtilLibraryName && TryLoadWhitelistedLibrary(AvUtilLibraryName, assembly, path, out nint handle) || + name == AvCodecLibraryName && TryLoadWhitelistedLibrary(AvCodecLibraryName, assembly, path, out handle)) { return handle; } diff --git a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs index 54705acaf..1e7582e50 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs @@ -275,12 +275,8 @@ namespace Ryujinx.Graphics.Shader.Instructions { location = 0; - if (!_attributes.TryGetValue(offset, out AttributeEntry entry)) - { - return IoVariable.Invalid; - } - - if (((StagesMask)(1 << (int)definitions.Stage) & entry.OutputMask) == StagesMask.None) + if (!_attributes.TryGetValue(offset, out AttributeEntry entry) || + ((StagesMask)(1 << (int)definitions.Stage) & entry.OutputMask) == StagesMask.None) { return IoVariable.Invalid; } diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs index b026c0415..e0eefc7ea 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs @@ -368,11 +368,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms copyCount += coordsCount * 2; } - if (isMultisample) - { - copyCount++; - } - else if (hasLodLevel) + if (isMultisample || hasLodLevel) { copyCount++; } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs index 6c1586cb9..06cfcb47d 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs @@ -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(); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs index cc5fa1674..5469541cd 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs @@ -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; } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index 62d9d310e..af106e98f 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -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; } diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs index 89620a076..8704af541 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs @@ -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(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(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; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs index 3256684f4..73c7a96fc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs @@ -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; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 7e3e4c0a2..67e98fdeb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -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 = [], diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs index 140c73573..7afcb2175 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs @@ -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; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs index ae61d0bf7..c62aa28a4 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs @@ -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; } diff --git a/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs b/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs index 693e03888..bd9b536f0 100644 --- a/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs +++ b/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs @@ -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(); diff --git a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs index d74e50a61..f59a235d3 100644 --- a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs +++ b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs @@ -112,12 +112,8 @@ namespace Ryujinx.Horizon.Sdk.Codec.Detail return CodecResult.InvalidChannelCount; } - if (!IsValidSampleRate(parameter.SampleRate)) - { - return CodecResult.InvalidSampleRate; - } - - if (!IsValidNumberOfStreams(parameter.NumberOfStreams, parameter.NumberOfStereoStreams, parameter.ChannelsCount)) + if (!IsValidSampleRate(parameter.SampleRate) + || !IsValidNumberOfStreams(parameter.NumberOfStreams, parameter.NumberOfStereoStreams, parameter.ChannelsCount)) { return CodecResult.InvalidSampleRate; } @@ -262,12 +258,8 @@ namespace Ryujinx.Horizon.Sdk.Codec.Detail return CodecResult.InvalidChannelCount; } - if (!IsValidSampleRate(parameter.SampleRate)) - { - return CodecResult.InvalidSampleRate; - } - - if (!IsValidNumberOfStreams(parameter.NumberOfStreams, parameter.NumberOfStereoStreams, parameter.ChannelsCount)) + if (!IsValidSampleRate(parameter.SampleRate) + || !IsValidNumberOfStreams(parameter.NumberOfStreams, parameter.NumberOfStereoStreams, parameter.ChannelsCount)) { return CodecResult.InvalidSampleRate; } diff --git a/src/Ryujinx.Input.SDL2/SDL2JoyCon.cs b/src/Ryujinx.Input.SDL2/SDL2JoyCon.cs index 2d6b476f6..ed3edfe25 100644 --- a/src/Ryujinx.Input.SDL2/SDL2JoyCon.cs +++ b/src/Ryujinx.Input.SDL2/SDL2JoyCon.cs @@ -352,14 +352,11 @@ namespace Ryujinx.Input.SDL2 public (float, float) GetStick(StickInputId inputId) { - if (inputId == StickInputId.Unbound) + if (inputId == StickInputId.Unbound || + inputId == StickInputId.Left && _joyConType == JoyConType.Right || + inputId == StickInputId.Right && _joyConType == JoyConType.Left) return (0.0f, 0.0f); - if (inputId == StickInputId.Left && _joyConType == JoyConType.Right || inputId == StickInputId.Right && _joyConType == JoyConType.Left) - { - return (0.0f, 0.0f); - } - (short stickX, short stickY) = GetStickXY(); float resultX = ConvertRawStickValue(stickX); diff --git a/src/Ryujinx.Memory/MemoryManagementUnix.cs b/src/Ryujinx.Memory/MemoryManagementUnix.cs index 1a7061026..31521aa5d 100644 --- a/src/Ryujinx.Memory/MemoryManagementUnix.cs +++ b/src/Ryujinx.Memory/MemoryManagementUnix.cs @@ -94,12 +94,8 @@ namespace Ryujinx.Memory throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); } - if (madvise(address, size, MADV_REMOVE) != 0) - { - throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); - } - - if (mprotect(address, size, MmapProts.PROT_NONE) != 0) + if (madvise(address, size, MADV_REMOVE) != 0 + || mprotect(address, size, MmapProts.PROT_NONE) != 0) { throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); } @@ -186,12 +182,7 @@ namespace Ryujinx.Memory fixed (byte* pFileName = fileName) { fd = mkstemp((IntPtr)pFileName); - if (fd == -1) - { - throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); - } - - if (unlink((IntPtr)pFileName) != 0) + if (fd == -1 || unlink((IntPtr)pFileName) != 0) { throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); }