Fix address_range start_length() constructor

Fixes an underflow when constructing start_length(0, 0).
This commit is contained in:
Eladash 2020-04-29 06:46:51 +03:00
parent 791ec95313
commit 0db91aa56b

View File

@ -60,21 +60,26 @@ namespace utils
return (start1 >= start2 && end1 <= end2);
}
address_range(u32 _start, u32 _end) : start(_start), end(_end) {}
constexpr address_range(u32 _start, u32 _end) : start(_start), end(_end) {}
public:
// Constructors
address_range() = default;
address_range(const address_range &other) : start(other.start), end(other.end) {}
constexpr address_range() = default;
constexpr address_range(const address_range &other) : start(other.start), end(other.end) {}
static inline address_range start_length(u32 _start, u32 _length)
static constexpr address_range start_length(u32 _start, u32 _length)
{
return address_range(_start, _start + (_length - 1));
if (!_length)
{
return {};
}
return {_start, _start + (_length - 1)};
}
static inline address_range start_end(u32 _start, u32 _end)
static constexpr address_range start_end(u32 _start, u32 _end)
{
return address_range(_start, _end);
return {_start, _end};
}
// Length