mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 10:51:50 -05:00
service: hid: Ensure GetNextEntryIndex can't fail
This commit is contained in:
parent
79d3cef8db
commit
b36fec486e
1 changed files with 3 additions and 3 deletions
|
@ -32,15 +32,15 @@ struct Lifo {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t GetPreviousEntryIndex() const {
|
std::size_t GetPreviousEntryIndex() const {
|
||||||
return static_cast<size_t>((buffer_tail + total_buffer_count - 1) % total_buffer_count);
|
return static_cast<size_t>((buffer_tail + max_buffer_size - 1) % max_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t GetNextEntryIndex() const {
|
std::size_t GetNextEntryIndex() const {
|
||||||
return static_cast<size_t>((buffer_tail + 1) % total_buffer_count);
|
return static_cast<size_t>((buffer_tail + 1) % max_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteNextEntry(const State& new_state) {
|
void WriteNextEntry(const State& new_state) {
|
||||||
if (buffer_count < total_buffer_count - 1) {
|
if (buffer_count < static_cast<s64>(max_buffer_size) - 1) {
|
||||||
buffer_count++;
|
buffer_count++;
|
||||||
}
|
}
|
||||||
buffer_tail = GetNextEntryIndex();
|
buffer_tail = GetNextEntryIndex();
|
||||||
|
|
Loading…
Reference in a new issue