[*] Solve a few compiler warnings. Mostly unrealistic u32 <-> u64 casts in element iteration and string operations we can reasonably ignore

This commit is contained in:
Reece Wilson 2022-06-14 16:59:37 +01:00
parent f166849e9f
commit 17b1a738ca
21 changed files with 79 additions and 78 deletions

View File

@ -62,6 +62,8 @@ namespace Aurora::IO
* IOPipeRequest
*/
bool bShouldReadUntilZero {};
bool bFlush {true};
};
struct IOPipeRequest
@ -103,7 +105,7 @@ namespace Aurora::IO
AuSPtr<IStreamWriter> writer;
bool shouldReadUntilZero;
bool shouldReadUntilZero {};
};
struct IIOPipeWork

View File

@ -69,7 +69,7 @@ namespace Aurora::Compression
out.resize(startingSize + ret);
read += deflatedLength;
read += AuUInt32(deflatedLength);
}
return true;

View File

@ -73,8 +73,8 @@ namespace Aurora::Compression
AuStreamReadWrittenPair_t Ingest_s(AuUInt32 input) override
{
AuUInt32 length = ZSTD_DStreamInSize();
AuUInt32 outFrameLength = ZSTD_DStreamOutSize();
AuUInt32 length = AuUInt32(ZSTD_DStreamInSize());
AuUInt32 outFrameLength = AuUInt32(ZSTD_DStreamOutSize());
AuUInt32 done {}, read {};
while (read < input)
@ -96,20 +96,20 @@ namespace Aurora::Compression
if (ZSTD_isError(ret))
{
SysPushErrorIO("Compression error: {}", ZSTD_getErrorName(ret));
this->availIn_ -= output.pos;
this->availIn_ -= AuUInt32(output.pos);
return AuMakePair(read, 0);
}
done += output.pos;
done += AuUInt32(output.pos);
if (!Write(reinterpret_cast<const AuUInt8 *>(output.dst),
output.pos))
AuUInt32(output.pos)))
{
return AuMakePair(read, 0);
}
}
this->availIn_ -= this->input_.pos;
this->availIn_ -= AuUInt32(this->input_.pos);
}
return {read, done};
@ -127,8 +127,8 @@ namespace Aurora::Compression
bool RunFlush(ZSTD_EndDirective type)
{
AuUInt32 length = ZSTD_DStreamInSize();
AuUInt32 outFrameLength = ZSTD_DStreamOutSize();
AuUInt32 length = AuUInt32(ZSTD_DStreamInSize());
AuUInt32 outFrameLength = AuUInt32(ZSTD_DStreamOutSize());
if (!this->availIn_)
{
@ -145,18 +145,18 @@ namespace Aurora::Compression
if (ZSTD_isError(ret))
{
SysPushErrorIO("Compression error: {}", ZSTD_getErrorName(ret));
this->availIn_ -= output.pos;
this->availIn_ -= AuUInt32(output.pos);
return {};
}
if (!Write(reinterpret_cast<const AuUInt8 *>(output.dst),
output.pos))
AuUInt32(output.pos)))
{
return false;
}
}
this->availIn_ -= this->input_.pos;
this->availIn_ -= AuUInt32(this->input_.pos);
return true;
}
@ -164,11 +164,11 @@ namespace Aurora::Compression
private:
AuSPtr<IO::IStreamReader> reader_;
ZSTD_CCtx *cctx_;
ZSTD_CCtx *cctx_ {};
char din_[ZSTD_BLOCKSIZE_MAX];
char dout_[ZSTD_BLOCKSIZE_MAX + 3 /*ZSTD_BLOCKHEADERSIZE*/];
char *curPtr_;
AuUInt32 availIn_;
char *curPtr_ {};
AuUInt32 availIn_ {};
ZSTD_inBuffer input_;
};
}

View File

@ -51,8 +51,8 @@ namespace Aurora::Compression
AuStreamReadWrittenPair_t Ingest_s(AuUInt32 input) override
{
AuUInt32 length = ZSTD_DStreamInSize();
AuUInt32 outFrameLength = ZSTD_DStreamOutSize();
AuUInt32 length = AuUInt32(ZSTD_DStreamInSize());
AuUInt32 outFrameLength = AuUInt32(ZSTD_DStreamOutSize());
AuUInt32 done {}, read {};
while (read < input)
@ -74,20 +74,20 @@ namespace Aurora::Compression
if (ZSTD_isError(ret))
{
SysPushErrorIO("Compression error: {}", ZSTD_getErrorName(ret));
this->availIn_ -= output.pos;
this->availIn_ -= AuUInt32(output.pos);
return AuMakePair(read, 0);
}
done += output.pos;
done += AuUInt32(output.pos);
if (!Write(reinterpret_cast<const AuUInt8 *>(output.dst),
output.pos))
AuUInt32(output.pos)))
{
return AuMakePair(read, 0);
}
}
this->availIn_ -= this->input_.pos;
this->availIn_ -= AuUInt32(this->input_.pos);
}
return {read, done};
@ -96,11 +96,11 @@ namespace Aurora::Compression
private:
AuSPtr<IO::IStreamReader> reader_;
ZSTD_DCtx *dctx_;
ZSTD_DCtx *dctx_ {};
char din_[ZSTD_BLOCKSIZE_MAX + 3 /*ZSTD_BLOCKHEADERSIZE*/];
char dout_[ZSTD_BLOCKSIZE_MAX];
char *curPtr_;
AuUInt32 availIn_;
char *curPtr_ {};
AuUInt32 availIn_ {};
ZSTD_inBuffer input_;
};
}

View File

@ -168,7 +168,7 @@ namespace Aurora::Console::ConsoleStd
gCanonicalBuffer.reserve(4096);
for (int i = 0; i < dwRecords; i++)
for (auto i = 0u; i < dwRecords; i++)
{
int z;
bool dBreak = false;
@ -697,7 +697,7 @@ namespace Aurora::Console::ConsoleStd
}
#elif defined(AURORA_IS_MODERNNT_DERIVED)
WriteStdOut(writeLine.data(), writeLine.size());
WriteStdOut(writeLine.data(), AuUInt32(writeLine.size()));
#endif
}
@ -806,7 +806,7 @@ namespace Aurora::Console::ConsoleStd
{
AU_LOCK_GUARD(gRingLock);
auto ret = stream.DecodeUTF8(gLineEncodedBuffer, gEncodedIndex, gLineBuffer.data() + gLineIndex, gLineBuffer.size() - gLineIndex);
auto ret = stream.DecodeUTF8(gLineEncodedBuffer, gEncodedIndex, gLineBuffer.data() + gLineIndex, AuUInt32(gLineBuffer.size() - gLineIndex));
// increment backline buffer
{

View File

@ -214,7 +214,7 @@ namespace Aurora::Console::ConsoleTTY
}
SetConsoleTextAttribute(hConsole, attrib);
TTYWrite(string, strlen(string));
TTYWrite(string, AuUInt32(strlen(string)));
SetConsoleTextAttribute(hConsole, FOREGROUND_WHITE);
}
@ -416,9 +416,9 @@ namespace Aurora::Console::ConsoleTTY
}
SMALL_RECT screen = {0, 0, res.first - 1, res.second - 1};
SetConsoleScreenBufferSize(gConsoles[0].h, COORD {(short)res.first, (short)res.second});
SetConsoleScreenBufferSize(gConsoles[1].h, COORD {(short)res.first, (short)res.second});
SMALL_RECT screen = {0, 0, AuInt16(res.first - 1), AuInt16(res.second - 1)};
SetConsoleScreenBufferSize(gConsoles[0].h, COORD {(AuInt16)res.first, (AuInt16)res.second});
SetConsoleScreenBufferSize(gConsoles[1].h, COORD {(AuInt16)res.first, (AuInt16)res.second});
SetConsoleWindowInfo(gConsoles[0].h, true, &screen);
SetConsoleWindowInfo(gConsoles[1].h, true, &screen);
@ -457,9 +457,9 @@ namespace Aurora::Console::ConsoleTTY
}
SMALL_RECT screen = {0, 0, res.first - 1, res.second - 1};
SetConsoleScreenBufferSize(gConsoles[0].h, COORD {(short)res.first, (short)res.second});
SetConsoleScreenBufferSize(gConsoles[1].h, COORD {(short)res.first, (short)res.second});
SMALL_RECT screen = {0, 0, AuInt16(res.first - 1), AuInt16(res.second - 1)};
SetConsoleScreenBufferSize(gConsoles[0].h, COORD {(AuInt16)res.first, (AuInt16)res.second});
SetConsoleScreenBufferSize(gConsoles[1].h, COORD {(AuInt16)res.first, (AuInt16)res.second});
SetConsoleWindowInfo(gConsoles[0].h, true, &screen);
SetConsoleWindowInfo(gConsoles[1].h, true, &screen);

View File

@ -208,7 +208,7 @@ namespace Aurora::Console::ConsoleTTY
}
this->noncanonicalCursorPos += GuessWidth(input);
this->noncanonicalCursorPosInBytes += input.size();
this->noncanonicalCursorPosInBytes += (int)input.size();
RedrawInput(true);
NoncanonicalSetCursor();
@ -434,7 +434,7 @@ namespace Aurora::Console::ConsoleTTY
if (locked)
{
this->noncanonicalCursorPos = GuessWidth(this->inputField);
this->noncanonicalCursorPosInBytes = this->inputField.size();
this->noncanonicalCursorPosInBytes = (int)this->inputField.size();
NoncanonicalSetCursor();
}
}
@ -478,7 +478,7 @@ namespace Aurora::Console::ConsoleTTY
if (locked)
{
this->noncanonicalCursorPos = GuessWidth(this->inputField);
this->noncanonicalCursorPosInBytes = this->inputField.size();
this->noncanonicalCursorPosInBytes = (int)this->inputField.size();
NoncanonicalSetCursor();
}
}
@ -486,7 +486,7 @@ namespace Aurora::Console::ConsoleTTY
void TTYConsole::HistoryUpdateCursor()
{
this->noncanonicalCursorPos = AuMin<AuUInt32>(this->noncanonicalCursorPos, GuessWidth(this->inputField));
this->noncanonicalCursorPosInBytes = AuMin<AuUInt32>(this->noncanonicalCursorPosInBytes, this->inputField.size());
this->noncanonicalCursorPosInBytes = AuMin<AuUInt32>(this->noncanonicalCursorPosInBytes, AuUInt32(this->inputField.size()));
RedrawInput(true);
NoncanonicalSetCursor();
}
@ -716,7 +716,7 @@ namespace Aurora::Console::ConsoleTTY
{
int XOffset = GetLeftBorder() + this->leftLogPadding;
auto itr = 0;
auto itr = str.npos;
itr = str.find('\t', itr);
while (itr != str.npos)
@ -740,7 +740,7 @@ namespace Aurora::Console::ConsoleTTY
AuTryInsert(this->screenBuffer, append);
str = str.substr(idx);
this->bScreenBufferDoesntMap |= str.size();
this->bScreenBufferDoesntMap |= bool(str.size());
}
}
@ -1004,7 +1004,7 @@ namespace Aurora::Console::ConsoleTTY
#if defined(AURORA_IS_MODERNNT_DERIVED)
DWORD idc;
WriteConsoleA(GetTTYHandle(), in.data(), in.size(), &idc, NULL);
WriteConsoleA(GetTTYHandle(), in.data(), AuUInt32(in.size()), &idc, NULL);
#else
ConsoleStd::WriteStdOutBlocking2(in.data(), in.size());
#endif
@ -1049,7 +1049,7 @@ namespace Aurora::Console::ConsoleTTY
#if defined(AURORA_IS_MODERNNT_DERIVED)
DWORD idc;
WriteConsoleA(GetTTYHandle(), in.data(), in.size(), &idc, NULL);
WriteConsoleA(GetTTYHandle(), in.data(), AuUInt32(in.size()), &idc, NULL);
#else
ConsoleStd::WriteStdOutBlocking2(in.data(), in.size());
#endif
@ -1204,7 +1204,7 @@ namespace Aurora::Console::ConsoleTTY
AuUInt32 TTYConsole::GuessWidth(const AuString &referenceLine)
{
return AuLocale::ConvertFromUTF8(referenceLine).size() ;
return AuUInt32(AuLocale::ConvertFromUTF8(referenceLine).size());
}
const AuString &TTYConsole::Stringify(const AuString &referenceLine, const AlignedString &string, bool spacing, bool brackets, bool extraPadding)
@ -1326,21 +1326,21 @@ namespace Aurora::Console::ConsoleTTY
}
// kanker
int toWrite = (brackets * stride) + DECOverheadA + spacing + string.str.size() + spacing + DECOverheadB + (brackets * stride);
int toSlice = stride * ((spacing * 2) + (brackets * 2) + string.str.size());
AuUInt toWrite = (brackets * stride) + DECOverheadA + spacing + string.str.size() + spacing + DECOverheadB + (brackets * stride);
AuUInt toSlice = stride * ((spacing * 2) + (brackets * 2) + string.str.size());
// brrr
if (toWrite <= toSlice)
{
// Fast path, pog. We dont need to allocate.
int strideTwo = brackets * stride;
AuUInt strideTwo = brackets * stride;
if (toWrite < toSlice)
{
int second = start + strideTwo + DECOverheadA + spacing + string.str.size() + spacing + DECOverheadB + right.size();
int two = start + (length * strideTwo);
int count = this->tempMemory.size() - two;
AuUInt second = start + strideTwo + DECOverheadA + spacing + string.str.size() + spacing + DECOverheadB + right.size();
AuUInt two = start + (length * strideTwo);
AuUInt count = this->tempMemory.size() - two;
AuMemmove(this->tempMemory.data() + second,
this->tempMemory.data() + two, this->tempMemory.size() - two);
@ -1550,7 +1550,7 @@ namespace Aurora::Console::ConsoleTTY
ETTYAlign TTYConsole::SetTitleAlignment(ETTYAlign newValue)
{
return AuExchange(this->headerTitle.align, newValue);
}
}
ETTYAlign TTYConsole::GetLogBoxTitleAlignment()
{

View File

@ -40,7 +40,7 @@ namespace Aurora::Console::Hooks
void WriteLoggerFailedWarning()
{
static AuString kLoggerError = "Something went from while dispatching a log line\n";
Console::WriteStdOut(kLoggerError.data(), kLoggerError.size());
Console::WriteStdOut(kLoggerError.data(), (AuUInt32)kLoggerError.size());
#if defined(AURORA_IS_MODERNNT_DERIVED)
OutputDebugStringA(kLoggerError.c_str());

View File

@ -33,7 +33,6 @@ namespace Aurora::Crypto::ECC
EHashType method,
AuByteBuffer &out)
{
prng_state yarrow_prng;
const int salt = 0;
if (!plainText.HasMemory())

View File

@ -23,7 +23,7 @@ extern "C"
AUKN_SYM mp_err s_mp_rand_platform(void *p, size_t n)
{
Aurora::RNG::ReadSecureRNG(p, n);
Aurora::RNG::ReadSecureRNG(p, AuUInt32(n));
return MP_OKAY;
}
}

View File

@ -12,7 +12,7 @@ extern "C"
{
AUKN_SYM int mbedtls_platform_entropy_poll(void *data, unsigned char *output, size_t len, size_t *olen)
{
Aurora::RNG::ReadSecureRNG(output, len);
Aurora::RNG::ReadSecureRNG(output, AuUInt32(len));
*olen = len;
return 0;
}

View File

@ -364,7 +364,7 @@ namespace Aurora::HWInfo
auto cpuInfo = cpuid(0);
auto nIds = cpuInfo.eax;
for (int i = 0; i <= nIds; ++i)
for (AuUInt i = 0; i <= nIds; ++i)
{
data.push_back(cpuid(i));
}
@ -407,7 +407,7 @@ namespace Aurora::HWInfo
char brand[0x40];
AuMemset(brand, 0, sizeof(brand));
for (int i = 0x80000000; i <= nExIds; ++i)
for (AuUInt i = 0x80000000u; i <= nExIds; ++i)
{
extdata.push_back(cpuid(i));
}

View File

@ -36,7 +36,7 @@ namespace Aurora::HWInfo
AuBST<AuUInt8, CpuInfo> cpuThreads;
AuUInt8 cpuCount;
cpuCount = length / sizeof(decltype(*cpuSetInfo));
cpuCount = AuUInt8(length / sizeof(decltype(*cpuSetInfo)));
for (int i = 0; i < cpuCount; i++)
{
@ -99,7 +99,7 @@ namespace Aurora::HWInfo
gCpuInfo.uSocket = 1;
gCpuInfo.uThreads = cpuCount;
gCpuInfo.uCores = cpuThreads.size();
gCpuInfo.uCores = AuUInt8(cpuThreads.size());
if (!GetLogicalProcessorInformation(sysinfo, &length))
{
@ -109,7 +109,7 @@ namespace Aurora::HWInfo
gCpuInfo.uSocket = 0;
length /= sizeof(*sysinfo);
for (auto i = 0; i < length; i++)
for (auto i = 0u; i < length; i++)
{
if (sysinfo[i].Relationship == RelationProcessorPackage)
{
@ -170,7 +170,7 @@ namespace Aurora::HWInfo
bool sparse = false;
bool hasHTCores = false;
for (auto i = 0; i < length; i++)
for (auto i = 0u; i < length; i++)
{
if (sysinfo[i].Relationship == RelationProcessorCore)
{

View File

@ -352,7 +352,7 @@ namespace Aurora::IO::Loop
this->handleArrayAnd_.reserve(this->loopSourceExs_.size() + this->addedSources_.size());
this->handleArrayOr_.reserve(this->loopSourceExs_.size() + this->addedSources_.size());
bShouldRebuild |= this->addedSources_.size();
bShouldRebuild |= bool(this->addedSources_.size());
//
for (auto &[source, timeout, callbacks] : this->addedSources_)
@ -690,7 +690,7 @@ namespace Aurora::IO::Loop
else
{
AuUInt uHandles = (source.source->Singular() ? 1 : source.source->GetHandles().size());
int sOffset = -(uHandles);
int sOffset = -((int)uHandles);
if (this->handleArrayOr_.size() > MAXIMUM_WAIT_OBJECTS)
{
this->RemoveSourceNB(source.source);

View File

@ -77,7 +77,7 @@ namespace Aurora::Locale::Encoding
{
auto preemptive = EncodeUTF8(binary, binaryLength, nullptr, 0);
if (!AuTryResize(out, preemptive.second)) return {};
auto main = EncodeUTF8(binary, preemptive.second, out.data(), out.size());
auto main = EncodeUTF8(binary, preemptive.second, out.data(), AuUInt32(out.size()));
if (main.second == 0) return {};
if (!AuTryResize(out, main.second)) return {};
out.shrink_to_fit();

View File

@ -21,7 +21,7 @@ namespace Aurora::Parse
return false;
}
auto status = base32_decode(in.data(), in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length, BASE32_RFC4648);
auto status = base32_decode(in.data(), (unsigned long)in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length, BASE32_RFC4648);
if (!AuTryResize(decoded, length))
{
SysPushErrorMem();
@ -41,7 +41,7 @@ namespace Aurora::Parse
return false;
}
auto status = base32_encode(reinterpret_cast<const unsigned char *>(buffer), length, &encoded[0], &outLength, BASE32_RFC4648);
auto status = base32_encode(reinterpret_cast<const unsigned char *>(buffer), (unsigned long)length, &encoded[0], &outLength, BASE32_RFC4648);
if (!AuTryResize(encoded, length))
{
SysPushErrorMem();

View File

@ -13,7 +13,7 @@ namespace Aurora::Parse
{
AUKN_SYM bool Base64Decode(const AuString &in, AuByteBuffer &decoded, bool url)
{
unsigned long length = in.size();
unsigned long length = (unsigned long)in.size();
if (!AuTryResize(decoded, length))
{
@ -24,11 +24,11 @@ namespace Aurora::Parse
int status;
if (url)
{
status = base64url_decode(in.data(), in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length);
status = base64url_decode(in.data(), (unsigned long)in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length);
}
else
{
status = base64_decode(in.data(), in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length);
status = base64_decode(in.data(), (unsigned long)in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length);
}
if (!AuTryResize(decoded, length))
@ -53,11 +53,11 @@ namespace Aurora::Parse
int status;
if (url)
{
status = base64url_encode(reinterpret_cast<const unsigned char*>(input.ptr), input.length, &encoded[0], &outLength);
status = base64url_encode(reinterpret_cast<const unsigned char*>(input.ptr), (unsigned long)input.length, &encoded[0], &outLength);
}
else
{
status = base64_encode(reinterpret_cast<const unsigned char*>(input.ptr), input.length, &encoded[0], &outLength);
status = base64_encode(reinterpret_cast<const unsigned char*>(input.ptr), (unsigned long)input.length, &encoded[0], &outLength);
}
if (!AuTryResize(encoded, outLength))

View File

@ -233,7 +233,7 @@ namespace Aurora::Parse
in.insert(in.size(), newLine);
}
for (int i = 0; i < length; )
for (auto i = 0u; i < length; )
{
AuUInt32 x, rowMax;

View File

@ -46,7 +46,7 @@ namespace Aurora::Process
return {};
}
auto length = GetModuleFileNameW(handle, &file[0], file.size());
auto length = GetModuleFileNameW(handle, &file[0], DWORD(file.size()));
if (!length)
{
return {};

View File

@ -259,7 +259,7 @@ namespace Aurora::Processes
if (handle != INVALID_HANDLE_VALUE && handle)
{
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 1);
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
this->bDontRelOut_ = true;
this->pipeStdOutWrite_ = handle;
@ -289,7 +289,7 @@ namespace Aurora::Processes
if (handle != INVALID_HANDLE_VALUE && handle)
{
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 1);
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
this->bDontRelErr_ = true;
this->pipeStdErrWrite_ = handle;
@ -319,7 +319,7 @@ namespace Aurora::Processes
if (handle != INVALID_HANDLE_VALUE && handle)
{
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 1);
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
this->bDontRelIn_ = true;
this->pipeStdInRead_ = handle;

View File

@ -76,7 +76,7 @@ namespace Aurora::RNG
AuString RandomDevice::NextString(AuUInt32 length, ERngStringCharacters type)
{
AuString ret(length, '\00');
NextString(ret.data(), ret.size(), type);
NextString(ret.data(), AuUInt32(ret.size()), type);
return ret;
}
@ -102,7 +102,7 @@ namespace Aurora::RNG
const auto &pair = rngSequence[static_cast<int>(type)];
for (auto i = 0; i < length; i++)
for (auto i = 0u; i < length; i++)
{
string[i] = pair.first[reinterpret_cast<const AuUInt8 *>(string)[i] % static_cast<int>(pair.second)];
}