[Ryujinx.HLE] Address dotnet-format issues (#5380)

* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0060 warnings

* Silence dotnet format IDE0052 warnings

* Address or silence dotnet format IDE1006 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA2208 warnings

* Address or silence dotnet format CA1806 and a few CA1854 warnings

* Address dotnet format CA2211 warnings

* Address dotnet format CA1822 warnings

* Address or silence dotnet format CA1069 warnings

* Make dotnet format succeed in style mode

* Address or silence dotnet format CA2211 warnings

* Address review comments

* Address dotnet format CA2208 warnings properly

* Make ProcessResult readonly

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Add previously silenced warnings back

I have no clue how these disappeared

* Revert formatting changes for while and for-loops

* Format if-blocks correctly

* Run dotnet format style after rebase

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format analyzers after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Fix a few disabled warnings

* Fix naming rule violation, Convert shader properties to auto-property and convert values to const

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Start working on disabled warnings

* Fix and silence a few dotnet-format warnings again

* Run dotnet format after rebase

* Use using declaration instead of block syntax

* Address IDE0251 warnings

* Address a few disabled IDE0060 warnings

* Silence IDE0060 in .editorconfig

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* First dotnet format pass

* Fix naming rule violations

* Fix typo

* Add trailing commas, use targeted new and use array initializer

* Fix build issues

* Fix remaining build issues

* Remove SuppressMessage for CA1069 where possible

* Address dotnet format issues

* Address formatting issues

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Add GetHashCode implementation for RenderingSurfaceInfo

* Explicitly silence CA1822 for every affected method in Syscall

* Address formatting issues in Demangler.cs

* Address review feedback

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Revert marking service methods as static

* Next dotnet format pass

* Address review feedback

---------

Co-authored-by: Ac_K <acoustik666@gmail.com>
This commit is contained in:
TSRBerry 2023-07-16 19:31:14 +02:00 committed by GitHub
parent fec8291c17
commit 326749498b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1015 changed files with 8173 additions and 7615 deletions

View file

@ -7,7 +7,6 @@ using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
@ -17,14 +16,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
[Service("bsd:u", false)]
class IClient : IpcService
{
private static readonly List<IPollManager> _pollManagers = new List<IPollManager>
private static readonly List<IPollManager> _pollManagers = new()
{
EventFileDescriptorPollManager.Instance,
ManagedSocketPollManager.Instance
ManagedSocketPollManager.Instance,
};
private BsdContext _context;
private bool _isPrivileged;
private readonly bool _isPrivileged;
public IClient(ServiceCtx context, bool isPrivileged) : base(context.Device.System.BsdServer)
{
@ -46,19 +45,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
private static AddressFamily ConvertBsdAddressFamily(BsdAddressFamily family)
{
switch (family)
return family switch
{
case BsdAddressFamily.Unspecified:
return AddressFamily.Unspecified;
case BsdAddressFamily.InterNetwork:
return AddressFamily.InterNetwork;
case BsdAddressFamily.InterNetworkV6:
return AddressFamily.InterNetworkV6;
case BsdAddressFamily.Unknown:
return AddressFamily.Unknown;
default:
throw new NotImplementedException(family.ToString());
}
BsdAddressFamily.Unspecified => AddressFamily.Unspecified,
BsdAddressFamily.InterNetwork => AddressFamily.InterNetwork,
BsdAddressFamily.InterNetworkV6 => AddressFamily.InterNetworkV6,
BsdAddressFamily.Unknown => AddressFamily.Unknown,
_ => throw new NotImplementedException(family.ToString()),
};
}
private LinuxError SetResultErrno(IFileDescriptor socket, int result)
@ -68,9 +62,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
private ResultCode SocketInternal(ServiceCtx context, bool exempt)
{
BsdAddressFamily domain = (BsdAddressFamily)context.RequestData.ReadInt32();
BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32();
ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32();
BsdAddressFamily domain = (BsdAddressFamily)context.RequestData.ReadInt32();
BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32();
ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32();
BsdSocketCreationFlags creationFlags = (BsdSocketCreationFlags)((int)type >> (int)BsdSocketCreationFlags.FlagsShift);
type &= BsdSocketType.TypeMask;
@ -101,8 +95,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
}
}
ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol);
newBsdSocket.Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking);
ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol)
{
Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking),
};
LinuxError errno = LinuxError.SUCCESS;
@ -210,7 +206,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
public ResultCode Select(ServiceCtx context)
{
int fdsCount = context.RequestData.ReadInt32();
int timeout = context.RequestData.ReadInt32();
int timeout = context.RequestData.ReadInt32();
(ulong readFdsInBufferPosition, ulong readFdsInBufferSize) = context.Request.GetBufferType0x21(0);
(ulong writeFdsInBufferPosition, ulong writeFdsInBufferSize) = context.Request.GetBufferType0x21(1);
@ -220,7 +216,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
(ulong writeFdsOutBufferPosition, ulong writeFdsOutBufferSize) = context.Request.GetBufferType0x22(1);
(ulong errorFdsOutBufferPosition, ulong errorFdsOutBufferSize) = context.Request.GetBufferType0x22(2);
List<IFileDescriptor> readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize));
List<IFileDescriptor> readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize));
List<IFileDescriptor> writeFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(writeFdsInBufferPosition, (int)writeFdsInBufferSize));
List<IFileDescriptor> errorFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(errorFdsInBufferPosition, (int)errorFdsInBufferSize));
@ -312,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
}
}
using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize);
using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize);
using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize);
using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize);
@ -330,10 +326,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
public ResultCode Poll(ServiceCtx context)
{
int fdsCount = context.RequestData.ReadInt32();
int timeout = context.RequestData.ReadInt32();
int timeout = context.RequestData.ReadInt32();
(ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
if (timeout < -1 || fdsCount < 0 || (ulong)(fdsCount * 8) > inputBufferSize)
{
@ -356,7 +354,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
events[i] = new PollEvent(pollEventData, fileDescriptor);
}
List<PollEvent> discoveredEvents = new List<PollEvent>();
List<PollEvent> discoveredEvents = new();
List<PollEvent>[] eventsByPollManager = new List<PollEvent>[_pollManagers.Count];
for (int i = 0; i < eventsByPollManager.Length; i++)
@ -389,7 +387,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
if (fdsCount != 0)
{
bool IsUnexpectedLinuxError(LinuxError error)
static bool IsUnexpectedLinuxError(LinuxError error)
{
return error != LinuxError.SUCCESS && error != LinuxError.ETIMEDOUT;
}
@ -478,16 +476,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// Recv(u32 socket, u32 flags) -> (i32 ret, u32 bsd_errno, array<i8, 0x22> message)
public ResultCode Recv(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
(ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22();
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
if (socket != null)
{
@ -508,17 +506,17 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// RecvFrom(u32 sock, u32 flags) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<i8, 0x22, 0> message, buffer<nn::socket::sockaddr_in, 0x22, 0x10>)
public ResultCode RecvFrom(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
(ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(0);
(ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(0);
(ulong sockAddrOutPosition, ulong sockAddrOutSize) = context.Request.GetBufferType0x22(1);
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
if (socket != null)
{
@ -530,7 +528,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
receiveRegion.Dispose();
if (sockAddrOutSize != 0 && sockAddrOutSize >= (ulong) Unsafe.SizeOf<BsdSockAddr>())
if (sockAddrOutSize != 0 && sockAddrOutSize >= (ulong)Unsafe.SizeOf<BsdSockAddr>())
{
context.Memory.Write(sockAddrOutPosition, BsdSockAddr.FromIPEndPoint(endPoint));
}
@ -548,16 +546,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// Send(u32 socket, u32 flags, buffer<i8, 0x21, 0>) -> (i32 ret, u32 bsd_errno)
public ResultCode Send(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
(ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21();
ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
if (socket != null)
{
@ -576,17 +574,19 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// SendTo(u32 socket, u32 flags, buffer<i8, 0x21, 0>, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno)
public ResultCode SendTo(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
(ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(0);
(ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(0);
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(1);
#pragma warning restore IDE0059
ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
if (socket != null)
{
@ -609,10 +609,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -652,10 +654,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -673,10 +677,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -694,10 +700,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
errno = LinuxError.ENOTCONN;
@ -721,10 +729,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -742,15 +752,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// GetSockOpt(u32 socket, u32 level, u32 option_name) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>)
public ResultCode GetSockOpt(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32();
BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32();
BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32();
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22();
WritableRegion optionValue = context.Memory.GetWritableRegion(bufferPosition, (int)bufferSize);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -770,10 +780,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
public ResultCode Listen(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int backlog = context.RequestData.ReadInt32();
int backlog = context.RequestData.ReadInt32();
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -787,12 +797,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// Ioctl(u32 fd, u32 request, u32 bufcount, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>)
public ResultCode Ioctl(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32();
int bufferCount = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
int bufferCount = context.RequestData.ReadInt32();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -801,7 +813,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
case BsdIoctl.AtMark:
errno = LinuxError.SUCCESS;
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
// FIXME: OOB not implemented.
context.Memory.Write(bufferPosition, 0);
@ -823,12 +837,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
public ResultCode Fcntl(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int cmd = context.RequestData.ReadInt32();
int arg = context.RequestData.ReadInt32();
int cmd = context.RequestData.ReadInt32();
int arg = context.RequestData.ReadInt32();
int result = 0;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = 0;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -856,16 +870,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// SetSockOpt(u32 socket, u32 level, u32 option_name, buffer<unknown, 0x21, 0> option_value) -> (i32 ret, u32 bsd_errno)
public ResultCode SetSockOpt(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32();
BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32();
BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32();
(ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x21();
ReadOnlySpan<byte> optionValue = context.Memory.GetSpan(bufferPos, (int)bufferSize);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -880,10 +894,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
public ResultCode Shutdown(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int how = context.RequestData.ReadInt32();
int how = context.RequestData.ReadInt32();
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
if (socket != null)
{
@ -924,9 +938,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize);
LinuxError errno = LinuxError.EBADF;
IFileDescriptor file = _context.RetrieveFileDescriptor(fd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
IFileDescriptor file = _context.RetrieveFileDescriptor(fd);
int result = -1;
if (file != null)
{
@ -951,9 +965,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
LinuxError errno = LinuxError.EBADF;
IFileDescriptor file = _context.RetrieveFileDescriptor(fd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
IFileDescriptor file = _context.RetrieveFileDescriptor(fd);
int result = -1;
if (file != null)
{
@ -990,8 +1004,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// DuplicateSocket(u32 fd, u64 reserved) -> (i32 ret, u32 bsd_errno)
public ResultCode DuplicateSocket(ServiceCtx context)
{
int fd = context.RequestData.ReadInt32();
int fd = context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong reserved = context.RequestData.ReadUInt64();
#pragma warning restore IDE0059
LinuxError errno = LinuxError.ENOENT;
int newSockFd = -1;
@ -1016,20 +1032,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// RecvMMsg(u32 fd, u32 vlen, u32 flags, u32 reserved, nn::socket::TimeVal timeout) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message);
public ResultCode RecvMMsg(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int vlen = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
int vlen = context.RequestData.ReadInt32();
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
uint reserved = context.RequestData.ReadUInt32();
TimeVal timeout = context.RequestData.ReadStruct<TimeVal>();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
uint reserved = context.RequestData.ReadUInt32();
#pragma warning restore IDE0059
TimeVal timeout = context.RequestData.ReadStruct<TimeVal>();
ulong receivePosition = context.Request.ReceiveBuff[0].Position;
ulong receiveLength = context.Request.ReceiveBuff[0].Size;
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
if (socket != null)
{
@ -1059,8 +1077,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// SendMMsg(u32 fd, u32 vlen, u32 flags) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message);
public ResultCode SendMMsg(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int vlen = context.RequestData.ReadInt32();
int socketFd = context.RequestData.ReadInt32();
int vlen = context.RequestData.ReadInt32();
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
ulong receivePosition = context.Request.ReceiveBuff[0].Position;
@ -1068,9 +1086,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
LinuxError errno = LinuxError.EBADF;
ISocket socket = _context.RetrieveSocket(socketFd);
int result = -1;
if (socket != null)
{
@ -1104,7 +1122,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
context.RequestData.BaseStream.Position += 4; // Padding
ulong initialValue = context.RequestData.ReadUInt64();
EventFileDescriptor newEventFile = new EventFileDescriptor(initialValue, flags);
EventFileDescriptor newEventFile = new(initialValue, flags);
LinuxError errno = LinuxError.SUCCESS;
@ -1118,4 +1136,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
return WriteBsdResult(context, newSockFd, errno);
}
}
}
}