Skip to content

Commit

Permalink
Dealt with some type casting warnings in common/values.cpp.
Browse files Browse the repository at this point in the history
This fixes the type of the local variable we use to store an
IO stream's original precision while outputing a `Scalar` value.
We extraneously cast from a `std::streamsize` (`int`) to `long`.

Also, this removes an extranous cast from `size_t` to `int` in
a vector iteration loop.

Review: https://reviews.apache.org/r/56675/
  • Loading branch information
hausdorff authored and kaysoky committed Feb 23, 2017
1 parent 039343a commit fac4c59
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/common/values.cpp
Expand Up @@ -73,7 +73,8 @@ ostream& operator<<(ostream& stream, const Value::Scalar& scalar)
{
// Output the scalar's full significant digits and save the old
// precision.
long precision = stream.precision(std::numeric_limits<double>::digits10);
std::streamsize precision =
stream.precision(std::numeric_limits<double>::digits10);

// We discard any additional precision (of the fractional part)
// from scalar resources before writing them to an ostream. This
Expand Down Expand Up @@ -609,12 +610,11 @@ Try<Value> parse(const string& text)
for (size_t i = 0; i < tokens.size(); i += 2) {
Value::Range* range = ranges->add_range();

int j = i;
Try<uint64_t> begin = numify<uint64_t>(tokens[j++]);
Try<uint64_t> end = numify<uint64_t>(tokens[j++]);
Try<uint64_t> begin = numify<uint64_t>(tokens[i]);
Try<uint64_t> end = numify<uint64_t>(tokens[i + 1]);
if (begin.isError() || end.isError()) {
return Error(
"Expecting non-negative integers in '" + tokens[j - 1] + "'");
"Expecting non-negative integers in '" + tokens[i] + "'");
}

range->set_begin(begin.get());
Expand Down

0 comments on commit fac4c59

Please sign in to comment.