Skip to content

Commit

Permalink
[GL] Array init; invert if-cnd; remove else branch
Browse files Browse the repository at this point in the history
The initialization avoids the maybe-uninitialized warning.
Inverting the loop for additional error info
  • Loading branch information
endJunction committed Oct 25, 2024
1 parent 8a09930 commit c4ddf42
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions GeoLib/IO/AsciiRasterInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,17 @@ std::vector<std::string> readFile(std::istream& in)

std::optional<std::array<double, 3>> readXyzCoordinates(std::string const& line)
{
std::array<double, 3> coords;
if (std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0], &coords[1],
&coords[2]) == 3)
{
return coords;
}
else
{
ERR("Raster::readXyzCoordinates() - Unexpected file format:\n{:s}",
line);
std::array<double, 3> coords = {0, 0, 0};
if (auto const n = std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0],
&coords[1], &coords[2]);
n != 3)
{
ERR("Raster::readXyzCoordinates() - Read {:d} doubles out of 3 "
"expected from the following line:\n{:s}",
n, line);
return std::nullopt;
}
return coords;
}

GeoLib::RasterHeader getXyzHeader(std::vector<std::string> const& lines)
Expand Down

0 comments on commit c4ddf42

Please sign in to comment.