win: Avoid warnings about conversion to smaller integer types

e.g.

d:\src\crashpad\crashpad\util\numeric\in_range_cast.h(35) : warning C4244: 'return' : conversion from 'unsigned __int64' to 'uint32_t', possible loss of data
d:\src\crashpad\crashpad\util\numeric\in_range_cast.h(35) : warning C4244: 'return' : conversion from '__int64' to 'int32_t', possible loss of data
        d:\src\crashpad\crashpad\util\numeric\in_range_cast_test.cc(54) : see reference to function template instantiation 'Destination crashpad::InRangeCast<int32_t,__int64>(Source,Destination)' being compiled
        with
        [
            Destination=int32_t
,            Source=__int64
        ]

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/800073003
This commit is contained in:
Scott Graham 2014-12-15 16:19:33 -08:00
parent e8ab9afd82
commit 1a17e7e643

View File

@ -32,11 +32,11 @@ namespace crashpad {
template <typename Destination, typename Source>
Destination InRangeCast(Source source, Destination default_value) {
if (base::IsValueInRangeForNumericType<Destination>(source)) {
return source;
return static_cast<Destination>(source);
}
LOG(WARNING) << "value " << source << " out of range";
return default_value;
return static_cast<Destination>(default_value);
}
} // namespace crashpad