Skip to content

Commit

Permalink
Fix I/O warning in IPC library
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Dec 8, 2024
1 parent 7444c01 commit 858cf45
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions YAMDCC.IPC/IO/PipeStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,22 @@ private int ReadLength()
{
byte[] lenbuf = new byte[SIZE_INT];
int bytesRead = BaseStream.Read(lenbuf, 0, SIZE_INT);
if (bytesRead == 0)
{
return 0;
}
return bytesRead != SIZE_INT
? throw new IOException($"Expected {SIZE_INT} bytes but read {bytesRead}")
: IPAddress.NetworkToHostOrder(BitConverter.ToInt32(lenbuf, 0));
return bytesRead == 0
? 0
: bytesRead != SIZE_INT
? throw new IOException($"Expected {SIZE_INT} bytes, but read {bytesRead}.")
: IPAddress.NetworkToHostOrder(BitConverter.ToInt32(lenbuf, 0));
}

/// <exception cref="MessagePackSerializationException"/>
private T ReadObject(int len)
{
byte[] data = new byte[len];
BaseStream.Read(data, 0, len);
return MessagePackSerializer.Deserialize<T>(data, _options);
int bytesRead = BaseStream.Read(data, 0, data.Length);
return bytesRead == len
? MessagePackSerializer.Deserialize<T>(data, _options)
: throw new IOException($"Expected {SIZE_INT} bytes, but read {bytesRead}.");

}
}
}

0 comments on commit 858cf45

Please sign in to comment.