Fix ~3500 analyser issues

See merge request ryubing/ryujinx!44
This commit is contained in:
MrKev
2025-05-30 17:08:34 -05:00
committed by LotP
parent 417df486b1
commit 361d0c5632
622 changed files with 3080 additions and 2652 deletions

View File

@@ -981,7 +981,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
{
return KernelResult.OutOfResource;
}
else if (recvListType == 1 || recvListType == 2)
else if (recvListType is 1 or 2)
{
ulong recvListBaseAddr;
ulong recvListEndAddr;

View File

@@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
return KernelResult.InvalidState;
}
Debug.Assert(permission == KMemoryPermission.Read || permission == KMemoryPermission.ReadAndExecute);
Debug.Assert(permission is KMemoryPermission.Read or KMemoryPermission.ReadAndExecute);
Result result = Owner.MemoryManager.MapPages(address, _pageList, MemoryState.CodeReadOnly, permission);

View File

@@ -253,6 +253,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
AliasRegionExtraSize = addrSpaceEnd / 8;
aliasRegion.Size += AliasRegionExtraSize;
}
break;
default:

View File

@@ -138,6 +138,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
sb.AppendLine($"\tX[{i:d2}]:\t{GetReg(i)}");
}
sb.AppendLine($"\tFP:\t{GetReg(29)}");
sb.AppendLine($"\tLR:\t{GetReg(30)}");
sb.AppendLine($"\tSP:\t{GetReg(31)}");
@@ -235,6 +236,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
info.SubName = Demangler.Parse(info.SubName);
}
info.SubOffset = info.Offset - symbol.Value;
}
else

View File

@@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
Pid = KernelContext.NewKipId();
if (Pid == 0 || Pid >= KernelConstants.InitialProcessId)
if (Pid is 0 or >= KernelConstants.InitialProcessId)
{
throw new InvalidOperationException($"Invalid KIP Id {Pid}.");
}
@@ -231,7 +231,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
Pid = KernelContext.NewProcessId();
if (Pid == ulong.MaxValue || Pid < KernelConstants.InitialProcessId)
if (Pid is ulong.MaxValue or < KernelConstants.InitialProcessId)
{
throw new InvalidOperationException($"Invalid Process Id {Pid}.");
}
@@ -309,7 +309,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
return KernelResult.InvalidCombination;
}
if (requiredKernelVersionMajor != KernelVersionMajor && requiredKernelVersionMajor < 3)
if (requiredKernelVersionMajor is not KernelVersionMajor and < 3)
{
return KernelResult.InvalidCombination;
}
@@ -461,7 +461,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
Result result = Result.Success;
if (_fullTlsPages.TryGetValue(tlsPageAddr, out KTlsPageInfo pageInfo))
{
// TLS page was full, free slot and move to free pages tree.
@@ -509,7 +508,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
return result;
}
private void GenerateRandomEntropy()
private static void GenerateRandomEntropy()
{
// TODO.
}
@@ -882,10 +881,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
if (State >= ProcessState.Started)
{
if (State == ProcessState.Started ||
State == ProcessState.Crashed ||
State == ProcessState.Attached ||
State == ProcessState.DebugSuspended)
if (State is ProcessState.Started or
ProcessState.Crashed or
ProcessState.Attached or
ProcessState.DebugSuspended)
{
SetState(ProcessState.Exiting);
@@ -925,9 +924,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
if (State >= ProcessState.Started)
{
if (State == ProcessState.Started ||
State == ProcessState.Attached ||
State == ProcessState.DebugSuspended)
if (State is ProcessState.Started or
ProcessState.Attached or
ProcessState.DebugSuspended)
{
SetState(ProcessState.Exiting);
@@ -1090,7 +1089,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
KernelContext.CriticalSection.Enter();
if (State != ProcessState.Exiting && State != ProcessState.Exited)
if (State is not ProcessState.Exiting and not ProcessState.Exited)
{
if (pause)
{

View File

@@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.HLE.HOS.Kernel.Process
{
[Flags]
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
enum ProcessCreationFlags
{
Is64Bit = 1 << 0,

View File

@@ -150,7 +150,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return handleTable.GenerateHandle(process, out handle);
}
public Result StartProcess(int handle, int priority, int cpuCore, ulong mainThreadStackSize)
public static Result StartProcess(int handle, int priority, int cpuCore, ulong mainThreadStackSize)
{
KProcess process = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KProcess>(handle);
@@ -1071,7 +1071,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
public Result QueryMemory(out MemoryInfo info, out ulong pageInfo, ulong address)
public static Result QueryMemory(out MemoryInfo info, out ulong pageInfo, ulong address)
{
KProcess process = KernelStatic.GetCurrentProcess();
@@ -1199,7 +1199,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidMemState;
}
if (permission > KMemoryPermission.ReadAndWrite || permission == KMemoryPermission.Write)
if (permission is > KMemoryPermission.ReadAndWrite or KMemoryPermission.Write)
{
return KernelResult.InvalidPermission;
}
@@ -1261,7 +1261,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidMemState;
}
if (permission > KMemoryPermission.ReadAndWrite || permission == KMemoryPermission.Write)
if (permission is > KMemoryPermission.ReadAndWrite or KMemoryPermission.Write)
{
return KernelResult.InvalidPermission;
}
@@ -1485,7 +1485,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidMemRange;
}
if (permission != KMemoryPermission.Read && permission != KMemoryPermission.ReadAndExecute)
if (permission is not KMemoryPermission.Read and not KMemoryPermission.ReadAndExecute)
{
return KernelResult.InvalidPermission;
}
@@ -1540,10 +1540,10 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidSize;
}
if (permission != KMemoryPermission.None &&
permission != KMemoryPermission.Read &&
permission != KMemoryPermission.ReadAndWrite &&
permission != KMemoryPermission.ReadAndExecute)
if (permission is not KMemoryPermission.None and
not KMemoryPermission.Read and
not KMemoryPermission.ReadAndWrite and
not KMemoryPermission.ReadAndExecute)
{
return KernelResult.InvalidPermission;
}
@@ -2009,6 +2009,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{
value = process.MemoryManager.GetMmUsedPages() * KPageTableBase.PageSize;
}
break;
case InfoType.ProgramId:
@@ -2040,12 +2041,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{
value = 0;
}
break;
case InfoType.AliasRegionExtraSize:
value = process.MemoryManager.AliasRegionExtraSize;
break;
}
break;
}
@@ -2093,6 +2096,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
value = (uint)resLimHandle;
}
break;
}
@@ -2134,7 +2138,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
case InfoType.ThreadTickCount:
{
if (subId < -1 || subId > 3)
if (subId is < (-1) or > 3)
{
return KernelResult.InvalidCombination;
}
@@ -2174,6 +2178,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
value = (ulong)KTimeManager.ConvertHostTicksToTicks(totalTimeRunning);
}
break;
}

View File

@@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
private readonly KernelContext _context;
private int _recursionCount;
// type is not Lock due to Monitor class usage
public object Lock { get; } = new();

View File

@@ -46,10 +46,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
_currentThread = null;
if (_srcCoresHighestPrioThreads == null)
{
_srcCoresHighestPrioThreads = new int[CpuCoresCount];
}
_srcCoresHighestPrioThreads ??= new int[CpuCoresCount];
}
private static int PreemptionPriorities(int index)

View File

@@ -537,7 +537,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
ThreadSchedState lowNibble = SchedFlags & ThreadSchedState.LowMask;
if (lowNibble != ThreadSchedState.Paused && lowNibble != ThreadSchedState.Running)
if (lowNibble is not ThreadSchedState.Paused and not ThreadSchedState.Running)
{
KernelContext.CriticalSection.Leave();