Skip to content

Commit

Permalink
Fix Clang warning -Wtautological-type-limit-compare
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRStevens committed Nov 3, 2024
1 parent ea66ade commit 685990e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NAS2D/Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ std::string Filesystem::readFile(const std::filesystem::path& filename) const
}

const auto fileSize = std::filesystem::file_size(filePath);
if constexpr (std::numeric_limits<decltype(fileSize)>::max() > std::numeric_limits<std::string::size_type>::max())
std::string fileBuffer;
if constexpr (std::numeric_limits<decltype(fileSize)>::max() > fileBuffer.max_size())
{
if (fileSize > std::numeric_limits<std::string::size_type>::max())
if (fileSize > fileBuffer.max_size())
{
throw std::runtime_error("Error opening file: " + filename.string() + " : File too large");
}
}
const auto bufferSize = static_cast<std::string::size_type>(fileSize);

std::string fileBuffer;
fileBuffer.resize(bufferSize);

file.read(fileBuffer.data(), static_cast<std::streamsize>(bufferSize));
Expand Down

0 comments on commit 685990e

Please sign in to comment.