mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-09 18:48:54 +02:00
misc: chore: Fix possible NullReferenceExceptions, suppress warnings
This commit is contained in:
@@ -173,7 +173,7 @@ namespace Ryujinx.HLE.HOS
|
||||
types.Clear();
|
||||
Mod<DirectoryInfo> mod = new("", null, true);
|
||||
|
||||
if (StrEquals(RomfsDir, modDir.Name))
|
||||
if (StrEquals(RomfsDir, modDir.Name) && modDir.Parent != null)
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.Parent.FullName.Equals(x.Path));
|
||||
var enabled = modData?.Enabled ?? true;
|
||||
@@ -181,7 +181,7 @@ namespace Ryujinx.HLE.HOS
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('R');
|
||||
}
|
||||
else if (StrEquals(ExefsDir, modDir.Name))
|
||||
else if (StrEquals(ExefsDir, modDir.Name) && modDir.Parent != null)
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.Parent.FullName.Equals(x.Path));
|
||||
var enabled = modData?.Enabled ?? true;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth
|
||||
|
||||
int initializeEventHandle;
|
||||
|
||||
if ((bool)debugMode)
|
||||
if ((bool)debugMode!)
|
||||
{
|
||||
if (BluetoothEventManager.InitializeBleDebugEventHandle == 0)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth
|
||||
{
|
||||
NxSettings.Settings.TryGetValue("bluetooth_debug!skip_boot", out object debugMode);
|
||||
|
||||
if ((bool)debugMode)
|
||||
if ((bool)debugMode!)
|
||||
{
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(BluetoothEventManager.RegisterBleDebugEventHandle);
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
DirectoryInfo archivePath = new DirectoryInfo(fullPath).Parent;
|
||||
|
||||
while (string.IsNullOrWhiteSpace(archivePath.Extension))
|
||||
while (string.IsNullOrWhiteSpace(archivePath?.Extension))
|
||||
{
|
||||
archivePath = archivePath.Parent;
|
||||
archivePath = archivePath?.Parent;
|
||||
}
|
||||
|
||||
if (archivePath.Extension == ".nsp" && File.Exists(archivePath.FullName))
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
if (fullPath.Contains('.'))
|
||||
if (fullPath!.Contains('.'))
|
||||
{
|
||||
ResultCode result = FileSystemProxyHelper.OpenFileSystemFromInternalFile(context, fullPath, out FileSystemProxy.IFileSystem fileSystem);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
_parameters[0] = context;
|
||||
|
||||
result = (ResultCode)processRequest.Invoke(service, _parameters);
|
||||
result = (ResultCode)processRequest.Invoke(service, _parameters)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -183,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
_parameters[0] = context;
|
||||
|
||||
result = (ResultCode)processRequest.Invoke(this, _parameters);
|
||||
result = (ResultCode)processRequest.Invoke(this, _parameters)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -409,7 +409,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
|
||||
bool openSuccess = i < P2pProxyServer.PrivatePortRange;
|
||||
|
||||
if (openSuccess)
|
||||
if (openSuccess && _hostedProxy != null)
|
||||
{
|
||||
Task<ushort> natPunchResult = _hostedProxy.NatPunch();
|
||||
|
||||
@@ -421,7 +421,10 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
request.ExternalProxyPort = natPunchResult.Result;
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (request.ExternalProxyPort == 0)
|
||||
{
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
ConstructorInfo constructor = deviceFileClass.GetConstructor([typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong)
|
||||
]);
|
||||
|
||||
NvDeviceFile deviceFile = (NvDeviceFile)constructor.Invoke([context, _clientMemory, _owner]);
|
||||
NvDeviceFile deviceFile = (NvDeviceFile)constructor?.Invoke([context, _clientMemory, _owner]);
|
||||
|
||||
deviceFile.Path = path;
|
||||
deviceFile?.Path = path;
|
||||
|
||||
fd = DeviceFileIdRegistry.Add(deviceFile);
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
||||
// TODO: Return invalid Fd error.
|
||||
}
|
||||
|
||||
channelDeviceFile.Channel.BindMemory(_asContext.Gmm);
|
||||
channelDeviceFile?.Channel.BindMemory(_asContext.Gmm);
|
||||
|
||||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Socket.Listen(backlog);
|
||||
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket listening: {ProtocolType}/{(Socket.LocalEndPoint as IPEndPoint).Port}");
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket listening: {ProtocolType}/{((IPEndPoint)Socket.LocalEndPoint).Port}");
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
@@ -573,7 +573,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
try
|
||||
{
|
||||
int receiveSize = (Socket as DefaultSocket).BaseSocket.Receive(ConvertMessagesToBuffer(message), ConvertBsdSocketFlags(flags), out SocketError socketError);
|
||||
int receiveSize = ((DefaultSocket)Socket).BaseSocket.Receive(ConvertMessagesToBuffer(message), ConvertBsdSocketFlags(flags), out SocketError socketError);
|
||||
|
||||
if (receiveSize > 0)
|
||||
{
|
||||
@@ -615,7 +615,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
try
|
||||
{
|
||||
int sendSize = (Socket as DefaultSocket).BaseSocket.Send(ConvertMessagesToBuffer(message), ConvertBsdSocketFlags(flags), out SocketError socketError);
|
||||
int sendSize = ((DefaultSocket)Socket).BaseSocket.Send(ConvertMessagesToBuffer(message), ConvertBsdSocketFlags(flags), out SocketError socketError);
|
||||
|
||||
if (sendSize > 0)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types
|
||||
{
|
||||
for (int index = 0; index < iovCount; index++)
|
||||
{
|
||||
if (message.Iov == null) continue;
|
||||
ulong iovLength = (ulong)message.Iov[index].Length;
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, in iovLength))
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
|
||||
NsdSettings = new NsdSettings
|
||||
{
|
||||
Initialized = true,
|
||||
TestMode = (bool)testMode,
|
||||
TestMode = (bool)testMode!,
|
||||
Environment = (string)environmentIdentifier,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -254,18 +254,23 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
|
||||
|
||||
public ResultCode GetServerCertificate(string hostname, Span<byte> certificates, out uint storageSize, out uint certificateCount)
|
||||
{
|
||||
byte[] rawCertData = _stream.RemoteCertificate.GetRawCertData();
|
||||
|
||||
storageSize = (uint)rawCertData.Length;
|
||||
certificateCount = 1;
|
||||
|
||||
if (rawCertData.Length > certificates.Length)
|
||||
if (_stream.RemoteCertificate != null)
|
||||
{
|
||||
return ResultCode.CertBufferTooSmall;
|
||||
byte[] rawCertData = _stream.RemoteCertificate.GetRawCertData();
|
||||
|
||||
storageSize = (uint)rawCertData.Length;
|
||||
certificateCount = 1;
|
||||
|
||||
if (rawCertData.Length > certificates.Length)
|
||||
{
|
||||
return ResultCode.CertBufferTooSmall;
|
||||
}
|
||||
|
||||
rawCertData.CopyTo(certificates);
|
||||
}
|
||||
|
||||
rawCertData.CopyTo(certificates);
|
||||
|
||||
storageSize = 0;
|
||||
certificateCount = 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace Ryujinx.HLE.UI
|
||||
|
||||
public bool Equals(RenderingSurfaceInfo other)
|
||||
{
|
||||
return ColorFormat == other.ColorFormat &&
|
||||
return other != null &&
|
||||
ColorFormat == other.ColorFormat &&
|
||||
Width == other.Width &&
|
||||
Height == other.Height &&
|
||||
Pitch == other.Pitch &&
|
||||
|
||||
Reference in New Issue
Block a user