Solve various signing warnings reported by GCC

This commit is contained in:
Jack Andersen 2019-06-09 16:49:17 -10:00
parent ed28576b99
commit 34b943c40f
5 changed files with 30 additions and 30 deletions

View File

@ -60,7 +60,7 @@ int main(int argc, char* argv[])
auto progFunc = [&](float prog, nod::SystemStringView name, size_t bytes) { auto progFunc = [&](float prog, nod::SystemStringView name, size_t bytes) {
nod::Printf(_SYS_STR("\r ")); nod::Printf(_SYS_STR("\r "));
if (bytes != -1) if (bytes != SIZE_MAX)
nod::Printf(_SYS_STR("\r%g%% %s %" PRISize " B"), prog * 100.f, name.data(), bytes); nod::Printf(_SYS_STR("\r%g%% %s %" PRISize " B"), prog * 100.f, name.data(), bytes);
else else
nod::Printf(_SYS_STR("\r%g%% %s"), prog * 100.f, name.data()); nod::Printf(_SYS_STR("\r%g%% %s"), prog * 100.f, name.data());
@ -89,7 +89,7 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
if (nod::DiscBuilderGCN::CalculateTotalSizeRequired(argv[2]) == -1) if (nod::DiscBuilderGCN::CalculateTotalSizeRequired(argv[2]) == UINT64_MAX)
return 1; return 1;
nod::EBuildResult ret; nod::EBuildResult ret;
@ -116,7 +116,7 @@ int main(int argc, char* argv[])
} }
bool dual = false; bool dual = false;
if (nod::DiscBuilderWii::CalculateTotalSizeRequired(argv[2], dual) == -1) if (nod::DiscBuilderWii::CalculateTotalSizeRequired(argv[2], dual) == UINT64_MAX)
return 1; return 1;
nod::EBuildResult ret; nod::EBuildResult ret;
@ -157,7 +157,7 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
if (nod::DiscMergerGCN::CalculateTotalSizeRequired(static_cast<nod::DiscGCN&>(*disc), argv[2]) == -1) if (nod::DiscMergerGCN::CalculateTotalSizeRequired(static_cast<nod::DiscGCN&>(*disc), argv[2]) == UINT64_MAX)
return 1; return 1;
nod::EBuildResult ret; nod::EBuildResult ret;
@ -199,7 +199,7 @@ int main(int argc, char* argv[])
} }
bool dual = false; bool dual = false;
if (nod::DiscMergerWii::CalculateTotalSizeRequired(static_cast<nod::DiscWii&>(*disc), argv[2], dual) == -1) if (nod::DiscMergerWii::CalculateTotalSizeRequired(static_cast<nod::DiscWii&>(*disc), argv[2], dual) == UINT64_MAX)
return 1; return 1;
nod::EBuildResult ret; nod::EBuildResult ret;

View File

@ -317,7 +317,7 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveBuildNodes(IPartWriteStream
size_t fileSz = ROUND_UP_32(e.m_fileSz); size_t fileSz = ROUND_UP_32(e.m_fileSz);
uint64_t fileOff = userAllocate(fileSz, ws); uint64_t fileOff = userAllocate(fileSz, ws);
if (fileOff == -1) if (fileOff == UINT64_MAX)
return false; return false;
m_fileOffsetsSizes[e.m_path] = std::make_pair(fileOff, fileSz); m_fileOffsetsSizes[e.m_path] = std::make_pair(fileOff, fileSz);
std::unique_ptr<IFileIO::IReadStream> rs = NewFileIO(e.m_path)->beginReadStream(); std::unique_ptr<IFileIO::IReadStream> rs = NewFileIO(e.m_path)->beginReadStream();
@ -466,7 +466,7 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodes(IPartWriteStream
size_t fileSz = ROUND_UP_32(e.m_fileSz); size_t fileSz = ROUND_UP_32(e.m_fileSz);
uint64_t fileOff = userAllocate(fileSz, ws); uint64_t fileOff = userAllocate(fileSz, ws);
if (fileOff == -1) if (fileOff == UINT64_MAX)
return false; return false;
m_fileOffsetsSizes[chKeyPath] = std::make_pair(fileOff, fileSz); m_fileOffsetsSizes[chKeyPath] = std::make_pair(fileOff, fileSz);
std::unique_ptr<IFileIO::IReadStream> rs = NewFileIO(e.m_path)->beginReadStream(); std::unique_ptr<IFileIO::IReadStream> rs = NewFileIO(e.m_path)->beginReadStream();
@ -518,7 +518,7 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodes(IPartWriteStream
size_t fileSz = ROUND_UP_32(ch.size()); size_t fileSz = ROUND_UP_32(ch.size());
uint64_t fileOff = userAllocate(fileSz, ws); uint64_t fileOff = userAllocate(fileSz, ws);
if (fileOff == -1) if (fileOff == UINT64_MAX)
return false; return false;
m_fileOffsetsSizes[chKeyPath] = std::make_pair(fileOff, fileSz); m_fileOffsetsSizes[chKeyPath] = std::make_pair(fileOff, fileSz);
std::unique_ptr<IPartReadStream> rs = ch.beginReadStream(); std::unique_ptr<IPartReadStream> rs = ch.beginReadStream();
@ -733,7 +733,7 @@ bool DiscBuilderBase::PartitionBuilderBase::buildFromDirectory(IPartWriteStream&
} }
size_t fileSz = ROUND_UP_32(dolStat.st_size); size_t fileSz = ROUND_UP_32(dolStat.st_size);
uint64_t fileOff = userAllocate(fileSz, ws); uint64_t fileOff = userAllocate(fileSz, ws);
if (fileOff == -1) if (fileOff == UINT64_MAX)
return false; return false;
m_dolOffset = fileOff; m_dolOffset = fileOff;
m_dolSize = fileSz; m_dolSize = fileSz;
@ -770,11 +770,11 @@ uint64_t DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeBuild(SystemSt
Sstat dolStat; Sstat dolStat;
if (Stat(dolIn.c_str(), &dolStat)) { if (Stat(dolIn.c_str(), &dolStat)) {
LogModule.report(logvisor::Error, _SYS_STR("unable to stat %s"), dolIn.c_str()); LogModule.report(logvisor::Error, _SYS_STR("unable to stat %s"), dolIn.c_str());
return -1; return UINT64_MAX;
} }
uint64_t totalSz = ROUND_UP_32(dolStat.st_size); uint64_t totalSz = ROUND_UP_32(dolStat.st_size);
if (!RecursiveCalculateTotalSize(totalSz, nullptr, filesIn.c_str())) if (!RecursiveCalculateTotalSize(totalSz, nullptr, filesIn.c_str()))
return -1; return UINT64_MAX;
return totalSz; return totalSz;
} }
@ -806,7 +806,7 @@ bool DiscBuilderBase::PartitionBuilderBase::mergeFromDirectory(IPartWriteStream&
size_t xferSz = partIn->getDOLSize(); size_t xferSz = partIn->getDOLSize();
size_t fileSz = ROUND_UP_32(xferSz); size_t fileSz = ROUND_UP_32(xferSz);
uint64_t fileOff = userAllocate(fileSz, ws); uint64_t fileOff = userAllocate(fileSz, ws);
if (fileOff == -1) if (fileOff == UINT64_MAX)
return false; return false;
m_dolOffset = fileOff; m_dolOffset = fileOff;
m_dolSize = fileSz; m_dolSize = fileSz;
@ -842,7 +842,7 @@ uint64_t DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(const IP
uint64_t totalSz = ROUND_UP_32(partIn->getDOLSize()); uint64_t totalSz = ROUND_UP_32(partIn->getDOLSize());
if (!RecursiveCalculateTotalSize(totalSz, &partIn->getFSTRoot(), filesIn.c_str())) if (!RecursiveCalculateTotalSize(totalSz, &partIn->getFSTRoot(), filesIn.c_str()))
return -1; return UINT64_MAX;
return totalSz; return totalSz;
} }

View File

@ -358,12 +358,12 @@ EBuildResult DiscBuilderGCN::buildFromDirectory(SystemStringView dirIn) {
uint64_t DiscBuilderGCN::CalculateTotalSizeRequired(SystemStringView dirIn) { uint64_t DiscBuilderGCN::CalculateTotalSizeRequired(SystemStringView dirIn) {
uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeBuild(dirIn, PartitionKind::Data, false); uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeBuild(dirIn, PartitionKind::Data, false);
if (sz == -1) if (sz == UINT64_MAX)
return -1; return UINT64_MAX;
sz += 0x30000; sz += 0x30000;
if (sz > 0x57058000) { if (sz > 0x57058000) {
LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x57058000); LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x57058000);
return -1; return UINT64_MAX;
} }
return sz; return sz;
} }
@ -403,8 +403,8 @@ EBuildResult DiscMergerGCN::mergeFromDirectory(SystemStringView dirIn) {
uint64_t DiscMergerGCN::CalculateTotalSizeRequired(DiscGCN& sourceDisc, SystemStringView dirIn) { uint64_t DiscMergerGCN::CalculateTotalSizeRequired(DiscGCN& sourceDisc, SystemStringView dirIn) {
uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(sourceDisc.getDataPartition(), dirIn); uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(sourceDisc.getDataPartition(), dirIn);
if (sz == -1) if (sz == UINT64_MAX)
return -1; return UINT64_MAX;
sz += 0x30000; sz += 0x30000;
if (sz > 0x57058000) { if (sz > 0x57058000) {
LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x57058000); LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x57058000);

View File

@ -1010,7 +1010,7 @@ public:
rs->read(tmdData.get(), tmdStat.st_size); rs->read(tmdData.get(), tmdStat.st_size);
ws.write(tmdData.get(), tmdStat.st_size); ws.write(tmdData.get(), tmdStat.st_size);
uint32_t tmdPadding = ROUND_UP_32(tmdStat.st_size) - tmdStat.st_size; uint32_t tmdPadding = ROUND_UP_32(tmdStat.st_size) - tmdStat.st_size;
for (int i = 0; i < tmdPadding; ++i) for (uint32_t i = 0; i < tmdPadding; ++i)
ws.write("", 1); ws.write("", 1);
rs = NewFileIO(certIn.c_str())->beginReadStream(); rs = NewFileIO(certIn.c_str())->beginReadStream();
@ -1146,13 +1146,13 @@ EBuildResult DiscBuilderWii::buildFromDirectory(SystemStringView dirIn) {
if (!ws) if (!ws)
return EBuildResult::Failed; return EBuildResult::Failed;
char zeroBytes[1024] = {}; char zeroBytes[1024] = {};
for (uint64_t i = 0; i < m_discCapacity; i += 1024) for (int64_t i = 0; i < m_discCapacity; i += 1024)
ws->write(zeroBytes, 1024); ws->write(zeroBytes, 1024);
} }
/* Assemble image */ /* Assemble image */
filledSz = pb.buildFromDirectory(dirIn); filledSz = pb.buildFromDirectory(dirIn);
if (filledSz == -1) if (filledSz == UINT64_MAX)
return EBuildResult::Failed; return EBuildResult::Failed;
else if (filledSz >= uint64_t(m_discCapacity)) { else if (filledSz >= uint64_t(m_discCapacity)) {
LogModule.report(logvisor::Error, "data partition exceeds disc capacity"); LogModule.report(logvisor::Error, "data partition exceeds disc capacity");
@ -1220,8 +1220,8 @@ EBuildResult DiscBuilderWii::buildFromDirectory(SystemStringView dirIn) {
uint64_t DiscBuilderWii::CalculateTotalSizeRequired(SystemStringView dirIn, bool& dualLayer) { uint64_t DiscBuilderWii::CalculateTotalSizeRequired(SystemStringView dirIn, bool& dualLayer) {
uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeBuild(dirIn, PartitionKind::Data, true); uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeBuild(dirIn, PartitionKind::Data, true);
if (sz == -1) if (sz == UINT64_MAX)
return -1; return UINT64_MAX;
auto szDiv = std::lldiv(sz, 0x1F0000); auto szDiv = std::lldiv(sz, 0x1F0000);
if (szDiv.rem) if (szDiv.rem)
++szDiv.quot; ++szDiv.quot;
@ -1230,7 +1230,7 @@ uint64_t DiscBuilderWii::CalculateTotalSizeRequired(SystemStringView dirIn, bool
dualLayer = (sz > 0x118240000); dualLayer = (sz > 0x118240000);
if (sz > 0x1FB4E0000) { if (sz > 0x1FB4E0000) {
LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x1FB4E0000); LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x1FB4E0000);
return -1; return UINT64_MAX;
} }
return sz; return sz;
} }
@ -1261,13 +1261,13 @@ EBuildResult DiscMergerWii::mergeFromDirectory(SystemStringView dirIn) {
if (!ws) if (!ws)
return EBuildResult::Failed; return EBuildResult::Failed;
char zeroBytes[1024] = {}; char zeroBytes[1024] = {};
for (uint64_t i = 0; i < m_builder.m_discCapacity; i += 1024) for (int64_t i = 0; i < m_builder.m_discCapacity; i += 1024)
ws->write(zeroBytes, 1024); ws->write(zeroBytes, 1024);
} }
/* Assemble image */ /* Assemble image */
filledSz = pb.mergeFromDirectory(static_cast<PartitionWii*>(m_sourceDisc.getDataPartition()), dirIn); filledSz = pb.mergeFromDirectory(static_cast<PartitionWii*>(m_sourceDisc.getDataPartition()), dirIn);
if (filledSz == -1) if (filledSz == UINT64_MAX)
return EBuildResult::Failed; return EBuildResult::Failed;
else if (filledSz >= uint64_t(m_builder.m_discCapacity)) { else if (filledSz >= uint64_t(m_builder.m_discCapacity)) {
LogModule.report(logvisor::Error, "data partition exceeds disc capacity"); LogModule.report(logvisor::Error, "data partition exceeds disc capacity");
@ -1328,8 +1328,8 @@ EBuildResult DiscMergerWii::mergeFromDirectory(SystemStringView dirIn) {
uint64_t DiscMergerWii::CalculateTotalSizeRequired(DiscWii& sourceDisc, SystemStringView dirIn, bool& dualLayer) { uint64_t DiscMergerWii::CalculateTotalSizeRequired(DiscWii& sourceDisc, SystemStringView dirIn, bool& dualLayer) {
uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(sourceDisc.getDataPartition(), dirIn); uint64_t sz = DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(sourceDisc.getDataPartition(), dirIn);
if (sz == -1) if (sz == UINT64_MAX)
return -1; return UINT64_MAX;
auto szDiv = std::lldiv(sz, 0x1F0000); auto szDiv = std::lldiv(sz, 0x1F0000);
if (szDiv.rem) if (szDiv.rem)
++szDiv.quot; ++szDiv.quot;
@ -1338,7 +1338,7 @@ uint64_t DiscMergerWii::CalculateTotalSizeRequired(DiscWii& sourceDisc, SystemSt
dualLayer = (sz > 0x118240000); dualLayer = (sz > 0x118240000);
if (sz > 0x1FB4E0000) { if (sz > 0x1FB4E0000) {
LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x1FB4E0000); LogModule.report(logvisor::Error, _SYS_STR("disc capacity exceeded [%" PRIu64 " / %" PRIu64 "]"), sz, 0x1FB4E0000);
return -1; return UINT64_MAX;
} }
return sz; return sz;
} }

@ -1 +1 @@
Subproject commit a2ffe70b4e1fa54d7013f327b45970e18e08901a Subproject commit ebe7463e671388902e56084453a464e35389324a