Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/System.Net.Sockets/src/System.Net.Sockets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
<OmitResources Condition="'$(TargetGroup)' == 'netfx'">true</OmitResources>
<ILLinkClearInitLocals Condition="'$(OS)' == 'Windows_NT'">true</ILLinkClearInitLocals>
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
Expand Down
22 changes: 11 additions & 11 deletions src/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static unsafe IPPacketInformation GetIPPacketInformation(Interop.Sys.Mes
return default(IPPacketInformation);
}

Interop.Sys.IPPacketInformation nativePacketInfo;
Interop.Sys.IPPacketInformation nativePacketInfo = default;
if (!Interop.Sys.TryGetIPPacketInformation(messageHeader, isIPv4, &nativePacketInfo))
{
return default(IPPacketInformation);
Expand All @@ -65,7 +65,7 @@ private static unsafe int Receive(SafeCloseSocket socket, SocketFlags flags, Spa
{
Debug.Assert(socketAddress != null || socketAddressLen == 0, $"Unexpected values: socketAddress={socketAddress}, socketAddressLen={socketAddressLen}");

long received;
long received = 0;
int sockAddrLen = socketAddress != null ? socketAddressLen : 0;

fixed (byte* sockAddr = socketAddress)
Expand Down Expand Up @@ -123,7 +123,7 @@ private static unsafe int Send(SafeCloseSocket socket, SocketFlags flags, ReadOn
IOVectorCount = 1
};

long bytesSent;
long bytesSent = 0;
errno = Interop.Sys.SendMessage(
socket.DangerousGetHandle(), // to minimize chances of handle recycling from misuse, this should use DangerousAddRef/Release, but it adds too much overhead
&messageHeader,
Expand Down Expand Up @@ -186,7 +186,7 @@ private static unsafe int Send(SafeCloseSocket socket, SocketFlags flags, IList<
IOVectorCount = iovCount
};

long bytesSent;
long bytesSent = 0;
errno = Interop.Sys.SendMessage(
socket.DangerousGetHandle(), // to minimize chances of handle recycling from misuse, this should use DangerousAddRef/Release, but it adds too much overhead
&messageHeader,
Expand Down Expand Up @@ -244,7 +244,7 @@ private static unsafe long SendFile(SafeCloseSocket socket, SafeFileHandle fileH

private static unsafe int Receive(SafeCloseSocket socket, SocketFlags flags, IList<ArraySegment<byte>> buffers, byte[] socketAddress, ref int socketAddressLen, out SocketFlags receivedFlags, out Interop.Error errno)
{
int available;
int available = 0;
errno = Interop.Sys.GetBytesAvailable(socket, &available);
if (errno != Interop.Error.SUCCESS)
{
Expand Down Expand Up @@ -353,7 +353,7 @@ private static unsafe int ReceiveMessageFrom(SafeCloseSocket socket, SocketFlags

Interop.Sys.MessageHeader messageHeader;

long received;
long received = 0;
fixed (byte* rawSocketAddress = socketAddress)
fixed (byte* b = &MemoryMarshal.GetReference(buffer))
{
Expand Down Expand Up @@ -432,7 +432,7 @@ private static unsafe int ReceiveMessageFrom(
ControlBufferLen = cmsgBufferLen
};

long received;
long received = 0;
errno = Interop.Sys.ReceiveMessage(
socket.DangerousGetHandle(), // to minimize chances of handle recycling from misuse, this should use DangerousAddRef/Release, but it adds too much overhead
&messageHeader,
Expand Down Expand Up @@ -470,7 +470,7 @@ private static unsafe int ReceiveMessageFrom(

public static unsafe bool TryCompleteAccept(SafeCloseSocket socket, byte[] socketAddress, ref int socketAddressLen, out IntPtr acceptedFd, out SocketError errorCode)
{
IntPtr fd;
IntPtr fd = IntPtr.Zero;
Interop.Error errno;
int sockAddrLen = socketAddressLen;
fixed (byte* rawSocketAddress = socketAddress)
Expand Down Expand Up @@ -545,7 +545,7 @@ public static unsafe bool TryStartConnect(SafeCloseSocket socket, byte[] socketA

public static unsafe bool TryCompleteConnect(SafeCloseSocket socket, int socketAddressLen, out SocketError errorCode)
{
Interop.Error socketError;
Interop.Error socketError = default;
Interop.Error err;
try
{
Expand Down Expand Up @@ -1307,7 +1307,7 @@ public static unsafe SocketError GetMulticastOption(SafeCloseSocket handle, Sock
Interop.Sys.MulticastOption.MULTICAST_ADD :
Interop.Sys.MulticastOption.MULTICAST_DROP;

Interop.Sys.IPv4MulticastOption opt;
Interop.Sys.IPv4MulticastOption opt = default;
Interop.Error err = Interop.Sys.GetIPv4MulticastOption(handle, optName, &opt);
if (err != Interop.Error.SUCCESS)
{
Expand All @@ -1332,7 +1332,7 @@ public static unsafe SocketError GetIPv6MulticastOption(SafeCloseSocket handle,
Interop.Sys.MulticastOption.MULTICAST_ADD :
Interop.Sys.MulticastOption.MULTICAST_DROP;

Interop.Sys.IPv6MulticastOption opt;
Interop.Sys.IPv6MulticastOption opt = default;
Interop.Error err = Interop.Sys.GetIPv6MulticastOption(handle, optName, &opt);
if (err != Interop.Error.SUCCESS)
{
Expand Down