HLE: Fix integer sign inconcistency accross the codebase (#2222)

* Make all title id instances unsigned

* Replace address and size with ulong instead of signed types

Long overdue change.
Also change some logics here and there to optimize with the new memory
manager.

* Address Ac_K's comments

* Remove uneeded cast all around

* Fixes some others misalignment
This commit is contained in:
Mary 2021-04-24 12:16:01 +02:00 committed by GitHub
parent c46f6879ff
commit 305f06eb71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 707 additions and 716 deletions

View file

@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
return ResultCode.PermissionDenied;
}
(long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21();
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
byte[] temp = new byte[bufferSize];
context.Memory.Read((ulong)bufferPosition, temp);
context.Memory.Read(bufferPosition, temp);
using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp))
{
@ -145,10 +145,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
// ParseTimeZoneBinary(buffer<nn::time::TimeZoneBinary, 0x21> timeZoneBinary) -> buffer<nn::time::TimeZoneRule, 0x16>
public ResultCode ParseTimeZoneBinary(ServiceCtx context)
{
(long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
(ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21();
long timeZoneRuleBufferPosition = context.Request.ReceiveBuff[0].Position;
long timeZoneRuleBufferSize = context.Request.ReceiveBuff[0].Size;
ulong timeZoneRuleBufferPosition = context.Request.ReceiveBuff[0].Position;
ulong timeZoneRuleBufferSize = context.Request.ReceiveBuff[0].Size;
if (timeZoneRuleBufferSize != 0x4000)
{
@ -162,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
byte[] temp = new byte[bufferSize];
context.Memory.Read((ulong)bufferPosition, temp);
context.Memory.Read(bufferPosition, temp);
using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp))
{
@ -188,9 +188,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
// ToCalendarTime(nn::time::PosixTime time, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo)
public ResultCode ToCalendarTime(ServiceCtx context)
{
long posixTime = context.RequestData.ReadInt64();
long bufferPosition = context.Request.SendBuff[0].Position;
long bufferSize = context.Request.SendBuff[0].Size;
long posixTime = context.RequestData.ReadInt64();
ulong bufferPosition = context.Request.SendBuff[0].Position;
ulong bufferSize = context.Request.SendBuff[0].Size;
if (bufferSize != 0x4000)
{
@ -220,7 +220,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
ResultCode resultCode = _timeZoneManager.ToCalendarTimeWithMyRules(posixTime, out CalendarInfo calendar);
if (resultCode == 0)
if (resultCode == ResultCode.Success)
{
context.ResponseData.WriteStruct(calendar);
}
@ -232,8 +232,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
// ToPosixTime(nn::time::CalendarTime calendarTime, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>)
public ResultCode ToPosixTime(ServiceCtx context)
{
long inBufferPosition = context.Request.SendBuff[0].Position;
long inBufferSize = context.Request.SendBuff[0].Size;
ulong inBufferPosition = context.Request.SendBuff[0].Position;
ulong inBufferSize = context.Request.SendBuff[0].Size;
CalendarTime calendarTime = context.RequestData.ReadStruct<CalendarTime>();
@ -249,12 +249,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
ResultCode resultCode = _timeZoneManager.ToPosixTime(rules, calendarTime, out long posixTime);
if (resultCode == 0)
if (resultCode == ResultCode.Success)
{
long outBufferPosition = context.Request.RecvListBuff[0].Position;
long outBufferSize = context.Request.RecvListBuff[0].Size;
ulong outBufferPosition = context.Request.RecvListBuff[0].Position;
ulong outBufferSize = context.Request.RecvListBuff[0].Size;
context.Memory.Write((ulong)outBufferPosition, posixTime);
context.Memory.Write(outBufferPosition, posixTime);
context.ResponseData.Write(1);
}
@ -269,12 +269,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
ResultCode resultCode = _timeZoneManager.ToPosixTimeWithMyRules(calendarTime, out long posixTime);
if (resultCode == 0)
if (resultCode == ResultCode.Success)
{
long outBufferPosition = context.Request.RecvListBuff[0].Position;
long outBufferSize = context.Request.RecvListBuff[0].Size;
ulong outBufferPosition = context.Request.RecvListBuff[0].Position;
ulong outBufferSize = context.Request.RecvListBuff[0].Size;
context.Memory.Write((ulong)outBufferPosition, posixTime);
context.Memory.Write(outBufferPosition, posixTime);
// There could be only one result on one calendar as leap seconds aren't supported.
context.ResponseData.Write(1);